From d436fed979049cefcc1b4a7d6aec30470b4decb7 Mon Sep 17 00:00:00 2001 From: rose with milk Date: Sat, 10 May 2025 10:47:59 +0200 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20test=5Fmain.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: rose with milk --- test_main.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 test_main.py diff --git a/test_main.py b/test_main.py new file mode 100644 index 0000000..651ea7a --- /dev/null +++ b/test_main.py @@ -0,0 +1,21 @@ +import pytest +from main import encrypt_telegram_id, decrypt_telegram_id + +# Тестовые данные +TEST_TELEGRAM_ID = "123456789" +ENCRYPTION_KEY = "your-encryption-key" # Замените на ваш ключ шифрования + + +@pytest.fixture(autouse=True) +def setup_env(monkeypatch): + # Устанавливаем переменную окружения для ключа шифрования + monkeypatch.setenv("ENCRYPTION_KEY", ENCRYPTION_KEY) + + +def test_encrypt_decrypt_telegram_id(): + # Шифруем и затем дешифруем идентификатор + encrypted_id = encrypt_telegram_id(TEST_TELEGRAM_ID) + decrypted_id = decrypt_telegram_id(encrypted_id) + + # Проверяем, что после дешифрования получаем исходный идентификатор + assert decrypted_id == TEST_TELEGRAM_ID \ No newline at end of file