Kairo-Jinkendo/backend/tests/conftest.py
Lars 564008be13
Some checks failed
Deploy Development / deploy (push) Successful in 38s
Test Suite / pytest-backend (push) Failing after 7s
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
AP0.2: Auth, Tenant, Actor Foundation mit Sessions, TenantContext und Tests.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-04 20:09:54 +02:00

50 lines
1.1 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_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()
def client():
import importlib
import main as main_module
importlib.reload(main_module)
from fastapi.testclient import TestClient
return TestClient(main_module.app)