BuyingAgent/tests/integration/test_ready.py
Lars c9c0ff96fc
Some checks failed
Deploy Development / deploy (push) Successful in 24s
Test Suite / pytest-backend (push) Failing after 14s
Test Suite / smoke-dev (push) Successful in 0s
Ergaenze die Kansho-analoge Test-Suite gegen buyingagent_test.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-03 11:20:30 +02:00

41 lines
1.1 KiB
Python

import pytest
from fastapi.testclient import TestClient
from sqlalchemy import text
from alembic.config import Config
from alembic.runtime.migration import MigrationContext
from alembic.script import ScriptDirectory
from app.main import app
from app.persistence.db import engine
pytestmark = pytest.mark.integration
client = TestClient(app)
@pytest.fixture(scope="module", autouse=True)
def require_postgres() -> None:
try:
with engine.connect() as connection:
connection.execute(text("SELECT 1"))
except Exception as exc:
pytest.skip(f"PostgreSQL not available: {exc}")
def test_health_ready_when_migrated() -> None:
response = client.get("/health/ready")
assert response.status_code == 200
body = response.json()
assert body["status"] == "ready"
assert "environment" in body
assert "engine_build" in body
def test_alembic_is_at_head() -> None:
config = Config("alembic.ini")
script = ScriptDirectory.from_config(config)
with engine.connect() as connection:
context = MigrationContext.configure(connection)
assert set(context.get_current_heads()) == set(script.get_heads())