Some checks failed
Deploy Development / deploy (push) Failing after 36s
Test Suite / pytest-backend (push) Failing after 0s
Test Suite / k6 /api/health Baseline (push) Has been skipped
Test Suite / playwright-smoke (push) Has been skipped
Test Suite / lint-backend (push) Successful in 2s
Test Suite / compose-smoke (push) Has been skipped
Co-authored-by: Cursor <cursoragent@cursor.com>
61 lines
1.4 KiB
Python
61 lines
1.4 KiB
Python
"""Shared pytest fixtures for AP0.2 auth tests."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
|
|
import pytest
|
|
|
|
os.environ.setdefault("SKIP_DB_MIGRATE", "1")
|
|
os.environ.setdefault("SKIP_SEEDS", "1")
|
|
os.environ.setdefault("SKIP_BOOTSTRAP", "1")
|
|
|
|
|
|
def _db_available() -> bool:
|
|
try:
|
|
import psycopg2
|
|
|
|
conn = psycopg2.connect(
|
|
host=os.getenv("DB_HOST", "localhost"),
|
|
port=os.getenv("DB_PORT", "5432"),
|
|
dbname=os.getenv("DB_NAME", "kairo_dev"),
|
|
user=os.getenv("DB_USER", "kairo_dev"),
|
|
password=os.getenv("DB_PASSWORD", "dev_password"),
|
|
)
|
|
conn.close()
|
|
return True
|
|
except Exception:
|
|
return False
|
|
|
|
|
|
pytestmark = pytest.mark.skipif(not _db_available(), reason="PostgreSQL nicht erreichbar")
|
|
|
|
|
|
@pytest.fixture(scope="session", autouse=True)
|
|
def _run_migrations():
|
|
import run_migrations
|
|
|
|
assert run_migrations.main() == 0
|
|
|
|
|
|
@pytest.fixture(scope="session", autouse=True)
|
|
def _seed_hygiene():
|
|
"""Vor/nach Tests pytest-Artefakte aus der geteilten Dev-DB entfernen."""
|
|
import run_seeds
|
|
|
|
run_seeds.main(["--only", "seed_001_cleanup_pytest_artifacts"])
|
|
yield
|
|
run_seeds.main(["--only", "seed_001_cleanup_pytest_artifacts"])
|
|
|
|
|
|
@pytest.fixture()
|
|
def client():
|
|
import importlib
|
|
|
|
import main as main_module
|
|
|
|
importlib.reload(main_module)
|
|
from fastapi.testclient import TestClient
|
|
|
|
return TestClient(main_module.app)
|