refactor(db)!: finalize pooled WNDB v2 migration
This commit is contained in:
@@ -2,7 +2,7 @@ from types import SimpleNamespace
|
||||
from uuid import uuid4
|
||||
|
||||
from fastapi.testclient import TestClient
|
||||
from sqlalchemy.exc import SQLAlchemyError
|
||||
import psycopg
|
||||
|
||||
from tests.conftest import build_test_app, install_stub, load_module_from_path
|
||||
|
||||
@@ -15,7 +15,7 @@ def _load_meta_module(monkeypatch):
|
||||
{
|
||||
"ProjectContext": object,
|
||||
"get_project_context": lambda: None,
|
||||
"get_project_pg_session": lambda: None,
|
||||
"get_project_pg_connection": lambda: None,
|
||||
"get_project_timescale_connection": lambda: None,
|
||||
"get_metadata_repository": lambda: None,
|
||||
},
|
||||
@@ -68,16 +68,18 @@ def test_meta_project_returns_map_extent(monkeypatch):
|
||||
def test_meta_db_health_returns_503_for_postgres_errors(monkeypatch):
|
||||
module = _load_meta_module(monkeypatch)
|
||||
|
||||
class BrokenSession:
|
||||
async def execute(self, _query):
|
||||
raise SQLAlchemyError("pg unavailable")
|
||||
class BrokenConnection:
|
||||
def cursor(self):
|
||||
raise psycopg.OperationalError("pg unavailable")
|
||||
|
||||
class DummyTimescaleConnection:
|
||||
def cursor(self):
|
||||
raise AssertionError("timescale should not be queried after postgres failure")
|
||||
|
||||
app = build_test_app(module.router, "/api/v1")
|
||||
app.dependency_overrides[module.get_project_pg_session] = lambda: BrokenSession()
|
||||
app.dependency_overrides[module.get_project_pg_connection] = (
|
||||
lambda: BrokenConnection()
|
||||
)
|
||||
app.dependency_overrides[module.get_project_timescale_connection] = lambda: DummyTimescaleConnection()
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user