feat(runtime): implement single-article consolidation runtime and modularize codebase
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
"""Contract tests for enrichment-response.schema.json."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import jsonschema
|
||||
|
||||
from src.runtime.core.config import create_schema_registry, load_schema
|
||||
|
||||
|
||||
def test_enrichment_response_schema_valid():
|
||||
schema = load_schema("enrichment-response.schema.json")
|
||||
registry = create_schema_registry()
|
||||
validator = jsonschema.Draft202012Validator(schema, registry=registry)
|
||||
|
||||
valid_response = {
|
||||
"sentiment": "positive",
|
||||
"tags": ["river plate", "futebol argentino", "copa sudamericana"],
|
||||
"evidence_candidate_ids": ["trafilatura_blk_001", "trafilatura_blk_002"],
|
||||
}
|
||||
|
||||
errors = list(validator.iter_errors(valid_response))
|
||||
assert len(errors) == 0, f"Schema errors: {[e.message for e in errors]}"
|
||||
|
||||
|
||||
def test_enrichment_response_schema_invalid_bounds():
|
||||
schema = load_schema("enrichment-response.schema.json")
|
||||
registry = create_schema_registry()
|
||||
validator = jsonschema.Draft202012Validator(schema, registry=registry)
|
||||
|
||||
# Less than 3 tags
|
||||
invalid_response = {
|
||||
"sentiment": "neutral",
|
||||
"tags": ["only_one_tag"],
|
||||
"evidence_candidate_ids": ["blk_01"],
|
||||
}
|
||||
errors = list(validator.iter_errors(invalid_response))
|
||||
assert len(errors) > 0
|
||||
Reference in New Issue
Block a user