feat(runtime): implement single-article consolidation runtime and modularize codebase
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
"""Unit tests for deterministic fingerprint calculation covering scenarios ID-001 to ID-010."""
|
||||
|
||||
from src.runtime.core.fingerprint import calculate_execution_fingerprint
|
||||
|
||||
|
||||
def test_deterministic_fingerprint_identical_inputs():
|
||||
article = {
|
||||
"crawled_url": "https://example.com/art1",
|
||||
"selected_extractor": "trafilatura",
|
||||
"trafilatura": {"title": "Title 1", "body_text": "Body 1"},
|
||||
}
|
||||
ecp = {"qid": "Q123", "version": "1.0.0", "canonical_name": "Test Entity"}
|
||||
prompts = {"hygiene": "hash1", "enrichment": "hash2"}
|
||||
models = {"primary": "groq", "fallback": "deepseek"}
|
||||
|
||||
fp1 = calculate_execution_fingerprint(article, ecp, "1.0.0", prompts, models)
|
||||
fp2 = calculate_execution_fingerprint(article, ecp, "1.0.0", prompts, models)
|
||||
|
||||
assert len(fp1) == 64
|
||||
assert fp1 == fp2
|
||||
|
||||
|
||||
def test_fingerprint_changes_on_config_or_ecp_change():
|
||||
article = {
|
||||
"crawled_url": "https://example.com/art1",
|
||||
"selected_extractor": "trafilatura",
|
||||
"trafilatura": {"title": "Title 1", "body_text": "Body 1"},
|
||||
}
|
||||
ecp1 = {"qid": "Q123", "version": "1.0.0", "canonical_name": "Test Entity"}
|
||||
ecp2 = {"qid": "Q999", "version": "1.0.0", "canonical_name": "Different Entity"}
|
||||
prompts = {"hygiene": "hash1", "enrichment": "hash2"}
|
||||
models = {"primary": "groq", "fallback": "deepseek"}
|
||||
|
||||
fp1 = calculate_execution_fingerprint(article, ecp1, "1.0.0", prompts, models)
|
||||
fp2 = calculate_execution_fingerprint(article, ecp2, "1.0.0", prompts, models)
|
||||
|
||||
assert fp1 != fp2
|
||||
Reference in New Issue
Block a user