File size: 651 Bytes
0109502
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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]