Files
mostovik-backend/tests/apps/exchange/test_models.py
Aleksandr Meshchriakov 3d298ce352
Some checks failed
CI/CD Pipeline / Run Tests (pull_request) Successful in 1m53s
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) Failing after 2m54s
CI/CD Pipeline / Telegram Notify Success (pull_request) Has been skipped
feat: expand platform APIs, sources, and test coverage
2026-03-17 12:56:48 +01:00

28 lines
1.0 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")