Files
ai-exchange/tests/unit/test_db_engine.py
T

22 lines
626 B
Python

import os
import unittest
os.environ.setdefault("DATABASE_URL", "postgresql+psycopg://user:pass@localhost:5432/ai_ict_test")
from src.db.engine import build_connect_args
class DbEngineTests(unittest.TestCase):
def test_postgresql_connect_args_include_timeout(self) -> None:
self.assertEqual(
build_connect_args("postgresql+psycopg://user:pass@localhost/db", 5),
{"connect_timeout": 5},
)
def test_non_postgresql_connect_args_are_empty(self) -> None:
self.assertEqual(build_connect_args("sqlite:///:memory:", 5), {})
if __name__ == "__main__":
unittest.main()