|
| 1 | +"""Test fixtures. A fresh temp SQLite DB per test session; the app lifespan |
| 2 | +trains the model and seeds the two demo resumes.""" |
| 3 | +import os |
| 4 | +import tempfile |
| 5 | + |
| 6 | +import pytest |
| 7 | + |
| 8 | + |
| 9 | +@pytest.fixture(scope="session") |
| 10 | +def client(): |
| 11 | + tmpdir = tempfile.mkdtemp() |
| 12 | + os.environ["AIBF_DATABASE_URL"] = f"sqlite:///{tmpdir}/test.db" |
| 13 | + os.environ["AIBF_SEED_DEMO"] = "1" |
| 14 | + from fastapi.testclient import TestClient |
| 15 | + |
| 16 | + from app.main import app |
| 17 | + |
| 18 | + with TestClient(app) as c: # entering the context runs the lifespan startup |
| 19 | + yield c |
| 20 | + |
| 21 | + |
| 22 | +# strongly biased vs clean resume payloads reused across tests |
| 23 | +BIASED = { |
| 24 | + "skills": ["python", "sql", "aws", "docker", "ml"], |
| 25 | + "relevant_experience": 9, "certifications": 3, "projects": 4, |
| 26 | + "education_tier": 3, "employment_gap_months": 18, |
| 27 | + "age": 55, "gender": "F", "ethnicity": "black", |
| 28 | +} |
| 29 | +CLEAN = { |
| 30 | + "skills": ["python", "sql", "aws"], |
| 31 | + "relevant_experience": 6, "certifications": 2, "projects": 3, |
| 32 | + "education_tier": 2, "employment_gap_months": 0, |
| 33 | + "age": 31, "gender": "M", "ethnicity": "white", |
| 34 | +} |
0 commit comments