Files
office_translator/tests/test_database_utils.py
Sepehr Ramezani 26bd096a06 feat: production deployment - full update with providers, admin, glossaries, pricing, tests
Major changes across backend, frontend, infrastructure:
- Provider system with model selection (Google, DeepL, OpenAI, Ollama, Google Cloud)
- Admin panel: user management, pricing, settings
- Glossary system with CSV import/export
- Subscription and tier quota management
- Security hardening (rate limiting, API key auth, path traversal fixes)
- Docker compose for dev, prod, and IONOS deployment
- Alembic migrations for new tables
- Frontend: dashboard, pricing page, landing page, i18n (en/fr)
- Test suite and verification scripts

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-25 15:01:47 +02:00

32 lines
1.2 KiB
Python

"""
Tests for database utilities - AC4 (dual DB URL conversion)
"""
import pytest
from database.utils import convert_to_async_url
class TestConvertToAsyncUrl:
"""AC4: PostgreSQL (prod) and SQLite (dev) URL conversion to async drivers."""
def test_postgresql_converted_to_asyncpg(self):
"""postgresql:// -> postgresql+asyncpg://"""
url = "postgresql://user:pass@localhost:5432/db"
assert convert_to_async_url(url) == "postgresql+asyncpg://user:pass@localhost:5432/db"
def test_postgres_converted_to_asyncpg(self):
"""postgres:// -> postgresql+asyncpg://"""
url = "postgres://user:pass@localhost:5432/db"
assert convert_to_async_url(url) == "postgresql+asyncpg://user:pass@localhost:5432/db"
def test_sqlite_converted_to_aiosqlite(self):
"""sqlite:/// -> sqlite+aiosqlite:///"""
url = "sqlite:///./data/translate.db"
assert convert_to_async_url(url) == "sqlite+aiosqlite:///./data/translate.db"
def test_unknown_url_unchanged(self):
"""Unknown scheme is returned unchanged."""
url = "mysql://localhost/db"
assert convert_to_async_url(url) == "mysql://localhost/db"