"""Unit tests for database session generation and URL construction.""" import pytest from app.database import _build_url, get_db def test_build_url_asyncpg_replacement(): """Ensure standard postgresql:// prefixes are converted to postgresql+asyncpg://.""" standard_url = "postgresql://user:pass@localhost:5432/studiq" async_url = _build_url(standard_url) assert async_url == "postgresql+asyncpg://user:pass@localhost:5432/studiq" def test_build_url_sqlite_passthrough(): """Ensure sqlite:// urls remain unchanged.""" sqlite_url = "sqlite+aiosqlite:///:memory:" assert _build_url(sqlite_url) == sqlite_url