Files
mostovik-backend/tests/apps/exchange/test_models.py
Aleksandr Meshchriakov 25176f31b4
Some checks failed
CI/CD Pipeline / Telegram Notify Success (push) Has been cancelled
CI/CD Pipeline / Run Tests (push) Has been cancelled
CI/CD Pipeline / Code Quality Checks (push) Has been cancelled
CI/CD Pipeline / Code Quality Checks (pull_request) Successful in 1m42s
CI/CD Pipeline / Run Tests (pull_request) Successful in 2m25s
CI/CD Pipeline / Telegram Notify Success (pull_request) Successful in 1m34s
fix pre-commit
2026-03-17 13:55:34 +01:00

32 lines
1.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Tests for exchange models."""
from apps.exchange.models import ExchangeConnection
from django.test import TestCase
from tests.apps.exchange.factories import ExchangeConnectionFactory
class ExchangeConnectionModelTest(TestCase):
def test_string_representation_and_plain_password_passthrough(self):
connection = ExchangeConnectionFactory(
username="postgres",
server="127.0.0.1",
port=5432,
database_name="target_db",
schema_name="public",
)
self.assertEqual(str(connection), "postgres@127.0.0.1:5432/target_db[public]")
self.assertEqual(
ExchangeConnection.decrypt_password("legacy-pass"), "legacy-pass"
)
def test_decrypt_password_raises_for_invalid_encrypted_token(self):
with self.assertRaisesMessage(
ValueError,
"Не удалось расшифровать пароль exchange connection",
):
ExchangeConnection.decrypt_password(
f"{ExchangeConnection.PASSWORD_PREFIX}invalid"
)