Migrate poo recorder and align Alembic naming
This commit is contained in:
+34
-3
@@ -13,7 +13,13 @@ from app.main import create_app
|
||||
|
||||
|
||||
def _make_alembic_config(database_url: str) -> Config:
|
||||
config = Config("alembic.ini")
|
||||
config = Config("alembic_location.ini")
|
||||
config.set_main_option("sqlalchemy.url", database_url)
|
||||
return config
|
||||
|
||||
|
||||
def _make_poo_alembic_config(database_url: str) -> Config:
|
||||
config = Config("alembic_poo.ini")
|
||||
config.set_main_option("sqlalchemy.url", database_url)
|
||||
return config
|
||||
|
||||
@@ -47,7 +53,13 @@ def ready_location_database(test_database_urls):
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def app(ready_location_database):
|
||||
def ready_poo_database(test_database_urls):
|
||||
command.upgrade(_make_poo_alembic_config(test_database_urls["poo_url"]), "head")
|
||||
return test_database_urls
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def app(ready_location_database, ready_poo_database):
|
||||
yield create_app()
|
||||
|
||||
|
||||
@@ -58,7 +70,7 @@ def client(app):
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def location_client(ready_location_database, monkeypatch: pytest.MonkeyPatch):
|
||||
def location_client(ready_location_database, ready_poo_database, monkeypatch: pytest.MonkeyPatch):
|
||||
database_url = ready_location_database["location_url"]
|
||||
|
||||
engine = create_engine(database_url, connect_args={"check_same_thread": False})
|
||||
@@ -72,3 +84,22 @@ def location_client(ready_location_database, monkeypatch: pytest.MonkeyPatch):
|
||||
yield client, engine
|
||||
|
||||
engine.dispose()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def poo_client(ready_location_database, ready_poo_database, monkeypatch: pytest.MonkeyPatch):
|
||||
database_url = ready_poo_database["poo_url"]
|
||||
|
||||
engine = create_engine(database_url, connect_args={"check_same_thread": False})
|
||||
session_local = sessionmaker(bind=engine, autoflush=False, autocommit=False)
|
||||
|
||||
import app.poo_db as poo_db
|
||||
|
||||
monkeypatch.setattr(poo_db, "poo_engine", engine)
|
||||
monkeypatch.setattr(poo_db, "PooSessionLocal", session_local)
|
||||
|
||||
fastapi_app = create_app()
|
||||
with TestClient(fastapi_app) as client:
|
||||
yield client, engine
|
||||
|
||||
engine.dispose()
|
||||
|
||||
Reference in New Issue
Block a user