Skip to content

Commit f276a85

Browse files
committed
feat(verify): reality-based cross-reference (Wikidata) + promotion veto
1 parent 4d58751 commit f276a85

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

tests/verify/test_promote_crossref.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,20 @@ def test_no_candidates_is_notfound():
4343
assert crossref.crossref_record(rec, FakeFetcher([])).decision == crossref.NOTFOUND
4444

4545

46+
def test_exact_heading_without_year_is_ambiguous():
47+
# Name matches an authoritative entity but there's no year to verify specs.
48+
rec = {"slug": "x", "name": "Widget 9000", "release_date": "2018-01-01"}
49+
f = FakeFetcher([Candidate("Widget 9000", "http://x", None)])
50+
assert crossref.crossref_record(rec, f).decision == crossref.AMBIGUOUS
51+
52+
53+
def test_model_suffix_matches_maker_prefixed_record():
54+
# Wikidata often labels without the maker prefix.
55+
rec = {"slug": "x", "name": "AMD Ryzen 7 5800X", "release_date": "2020-11-05"}
56+
f = FakeFetcher([Candidate("Ryzen 7 5800X", "http://x", 2020)])
57+
assert crossref.crossref_record(rec, f).decision == crossref.CONFIRM
58+
59+
4660
def test_normalize_heading():
4761
assert crossref.normalize_heading("iPhone XR") == "iphonexr"
4862
assert crossref.normalize_heading("Core i9-14900K") == "corei914900k"
@@ -135,6 +149,17 @@ def test_yellow_with_crossref_confirm_promotes():
135149
assert d.promote and d.reason == "crossref-confirm"
136150

137151

152+
def test_crossref_contradict_vetoes_even_green():
153+
# Reality veto: a green record with a live source is NOT promoted if an
154+
# authoritative source contradicts its specs.
155+
cache = {"https://en.wikipedia.org/wiki/X": {"alive": True}}
156+
d = promote.decide(
157+
band="green", source_urls=["https://en.wikipedia.org/wiki/X"],
158+
url_cache=cache, crossref_decision="contradict",
159+
)
160+
assert not d.promote and d.reason == "crossref-contradict"
161+
162+
138163
def test_dead_t1_does_not_promote():
139164
cache = {"https://en.wikipedia.org/wiki/X": {"alive": False}}
140165
d = promote.decide(band="green", source_urls=["https://en.wikipedia.org/wiki/X"],

0 commit comments

Comments
 (0)