Spaces:
Sleeping

File size: 638 Bytes
2026abe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
"""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