from pipeline.nim_schema import validate_nim_response TOPICS = {"functions", "comprehensions"} def good(): return { "valid": True, "scores": {"correctness": 95, "instruction_alignment": 94, "quality": 90, "training_value": 92, "scope_fit": 95}, "overall_score": 93, "dominant_topic": "functions", "secondary_topics": [], "summary": "Defines a function.", "issues": [], } def test_valid_schema(): assert validate_nim_response(good(), TOPICS)[0] def test_unknown_topic(): x = good() x["dominant_topic"] = "invented_topic" assert not validate_nim_response(x, TOPICS)[0]