This commit is contained in:
+10
-3
@@ -9,10 +9,12 @@ from apps.jobs.models import AiAnalysisCache
|
||||
from apps.jobs.services import ai as ai_service
|
||||
from apps.jobs.services.ai import analyze_job_text
|
||||
|
||||
pytestmark = pytest.mark.django_db
|
||||
|
||||
|
||||
def _evaluation_cases() -> list[dict[str, object]]:
|
||||
path = Path(__file__).resolve().parents[1] / "fixtures" / "ai" / "evaluation_set.json"
|
||||
return json.loads(path.read_text(encoding="utf-8"))["cases"]
|
||||
path = Path(__file__).resolve().parents[2] / "fixtures" / "ai" / "evaluation_set.json"
|
||||
return json.loads(path.read_text(encoding="utf-8-sig"))["cases"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("case", _evaluation_cases(), ids=lambda case: case["id"])
|
||||
@@ -31,6 +33,7 @@ def test_ai_evaluation_cases(monkeypatch, case):
|
||||
return
|
||||
|
||||
if case["response_type"] == "timeout":
|
||||
|
||||
class FakeClient:
|
||||
def __init__(self, *args, **kwargs):
|
||||
pass
|
||||
@@ -46,6 +49,7 @@ def test_ai_evaluation_cases(monkeypatch, case):
|
||||
|
||||
monkeypatch.setattr(httpx, "Client", FakeClient)
|
||||
else:
|
||||
|
||||
class FakeClient:
|
||||
def __init__(self, *args, **kwargs):
|
||||
pass
|
||||
@@ -112,7 +116,10 @@ def test_ai_cache_reuses_result(monkeypatch):
|
||||
nonlocal calls
|
||||
calls += 1
|
||||
return _fake_response(
|
||||
'{"summary_nl":"Gevalideerde IT-ops advertentie.","features":{"support_ratio":0.03,"consultancy_ratio":0.01,"travel_ratio":0.02,"seniority":"senior","evidence":["IT"]},"warnings":[]}'
|
||||
'{"summary_nl":"Gevalideerde IT-ops advertentie.",'
|
||||
'"features":{"support_ratio":0.03,"consultancy_ratio":0.01,'
|
||||
'"travel_ratio":0.02,"seniority":"senior","evidence":["IT"]},'
|
||||
'"warnings":[]}'
|
||||
)
|
||||
|
||||
monkeypatch.setattr(httpx, "Client", FakeClient)
|
||||
|
||||
Reference in New Issue
Block a user