test: cover end-to-end Nemotron review path
Browse files- tests/test_app.py +39 -0
tests/test_app.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import sys
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
|
| 4 |
+
from packetcourt.models import AgentReview
|
| 5 |
+
|
| 6 |
+
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
| 7 |
+
import app
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def test_run_audit_validates_nemotron_dict_into_agent_review(monkeypatch):
|
| 11 |
+
monkeypatch.setattr(app, "nemotron_is_configured", lambda: True)
|
| 12 |
+
monkeypatch.setattr(
|
| 13 |
+
app,
|
| 14 |
+
"nemotron_review",
|
| 15 |
+
lambda snapshot: {
|
| 16 |
+
"status": "COMPLETE",
|
| 17 |
+
"priority": "Supplementary wording that should be normalized.",
|
| 18 |
+
"evidence_request": "",
|
| 19 |
+
"rationale": "All claim evidence paths completed.",
|
| 20 |
+
"model": "nvidia/Nemotron-Mini-4B-Instruct",
|
| 21 |
+
},
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
result = app.run_audit("SUGAR FREE", "Nutrition per 100g: Total Sugars 0g. Net Weight 200g.")
|
| 25 |
+
|
| 26 |
+
assert isinstance(result.agent_review, AgentReview)
|
| 27 |
+
assert result.agent_review.status == "COMPLETE"
|
| 28 |
+
assert result.agent_review.priority == "No additional claim-resolving evidence is required."
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def test_run_audit_preserves_nemotron_validation_error(monkeypatch):
|
| 32 |
+
monkeypatch.setattr(app, "nemotron_is_configured", lambda: True)
|
| 33 |
+
monkeypatch.setattr(app, "nemotron_review", lambda snapshot: "not a review object")
|
| 34 |
+
|
| 35 |
+
result = app.run_audit("SUGAR FREE", "Nutrition per 100g: Total Sugars 0g. Net Weight 200g.")
|
| 36 |
+
|
| 37 |
+
assert isinstance(result.agent_review, AgentReview)
|
| 38 |
+
assert result.agent_review.status == "UNAVAILABLE"
|
| 39 |
+
assert "ValidationError" in result.agent_review.rationale
|