import pytest from fastapi.testclient import TestClient from app.core.db import Base, SessionLocal, engine from app.main import app from app.seed_loader import reset_and_seed @pytest.fixture(scope="session", autouse=True) def _seeded_database(): Base.metadata.create_all(engine) db = SessionLocal() try: reset_and_seed(db) finally: db.close() yield @pytest.fixture def client() -> TestClient: return TestClient(app) def login(client: TestClient, role: str) -> TestClient: response = client.post("/api/v1/demo/login", json={"role": role}) assert response.status_code == 200 return client @pytest.fixture def ops_client(client: TestClient) -> TestClient: return login(client, "operations_manager") @pytest.fixture def employee_client(client: TestClient) -> TestClient: return login(client, "rental_employee")