Demo auth, seed import/reset, dashboard, vehicle/booking list+detail, audit trail. Backend: 19 tests passing, ruff clean. Frontend: React Router shell, typed API client, responsive pages. Verified end-to-end via curl and browser.
39 lines
878 B
Python
39 lines
878 B
Python
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")
|