mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-21 20:59:05 +00:00
feat: migrate SQLAlchemy from 1.4 to 2.0 with ORM style
- Remove encode/databases dependency, use native SQLAlchemy 2.0 async - Convert all table definitions to Declarative Mapping pattern - Update all controllers to accept session parameter (dependency injection) - Convert all queries from Core style to ORM style - Remove PostgreSQL compatibility checks (PostgreSQL only now) - Add proper typing for engine and session factories
This commit is contained in:
@@ -69,17 +69,19 @@ def postgres_service(docker_ip, docker_services):
|
||||
@pytest.fixture(scope="function", autouse=True)
|
||||
@pytest.mark.asyncio
|
||||
async def setup_database(postgres_service):
|
||||
from reflector.db import engine, metadata, get_database # noqa
|
||||
from reflector.db import get_engine
|
||||
from reflector.db.base import metadata
|
||||
|
||||
metadata.drop_all(bind=engine)
|
||||
metadata.create_all(bind=engine)
|
||||
database = get_database()
|
||||
async_engine = get_engine()
|
||||
|
||||
async with async_engine.begin() as conn:
|
||||
await conn.run_sync(metadata.drop_all)
|
||||
await conn.run_sync(metadata.create_all)
|
||||
|
||||
try:
|
||||
await database.connect()
|
||||
yield
|
||||
finally:
|
||||
await database.disconnect()
|
||||
await async_engine.dispose()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
@@ -196,9 +196,9 @@ async def test_room_list_with_ics_enabled_filter():
|
||||
assert len(all_rooms) == 3
|
||||
|
||||
# Filter for ICS-enabled rooms (would need to implement this in controller)
|
||||
ics_rooms = [r for r in all_rooms if r["ics_enabled"]]
|
||||
ics_rooms = [r for r in all_rooms if r.ics_enabled]
|
||||
assert len(ics_rooms) == 2
|
||||
assert all(r["ics_enabled"] for r in ics_rooms)
|
||||
assert all(r.ics_enabled for r in ics_rooms)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
||||
Reference in New Issue
Block a user