File size: 708 Bytes
7c6ffa6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | from __future__ import annotations
def test_ask_survives_best_effort_tracking_failures(client, monkeypatch):
from app.routes import ask
def fail_tracking(*_args, **_kwargs):
raise RuntimeError("tracking failure")
monkeypatch.setattr(ask, "record_topic_attempt", fail_tracking)
monkeypatch.setattr(ask, "record_generation", fail_tracking)
monkeypatch.setattr(ask, "increment_usage", fail_tracking)
response = client.post(
"/ask",
json={
"question": "Teach photosynthesis in exam scoring points.",
"mode": "exam_answer",
},
)
assert response.status_code == 200
body = response.json()
assert "answer" in body
|