feat: preserve gear components through catch imports
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import pytest
|
||||
|
||||
from rf4_research.gear_crosswalk import (
|
||||
CanonicalGear,
|
||||
GearIdentity,
|
||||
suggest_gear_crosswalk,
|
||||
)
|
||||
|
||||
|
||||
def test_gear_crosswalk_matches_exact_name_and_category_only() -> None:
|
||||
canonical = [
|
||||
CanonicalGear("lure:spiker-2", "Spiker #2", "lure", ("Spiker 2",), brand="RF4"),
|
||||
CanonicalGear("rig:method-popup", "Method Popup", "rig"),
|
||||
]
|
||||
identities = [
|
||||
GearIdentity("rf4db", "spiker-2", " spiker #2 ", "lure", brand="RF4"),
|
||||
GearIdentity("rf4db", "method-popup", "Method Popup", "lure"),
|
||||
GearIdentity("rf4db", "unknown", "Unknown bait", "bait"),
|
||||
]
|
||||
rows = suggest_gear_crosswalk(canonical, identities)
|
||||
assert [(row.status, row.canonical_keys) for row in rows] == [
|
||||
("exact", ("lure:spiker-2",)), ("unmatched", ()), ("unmatched", ()),
|
||||
]
|
||||
|
||||
|
||||
def test_gear_crosswalk_does_not_auto_select_ambiguous_or_brand_mismatch() -> None:
|
||||
canonical = [
|
||||
CanonicalGear("a", "Test Hook", "hook", brand="A"),
|
||||
CanonicalGear("b", "Test Hook", "hook", brand="B"),
|
||||
]
|
||||
identities = [
|
||||
GearIdentity("rf4db", "1", "Test Hook", "hook"),
|
||||
GearIdentity("rf4db", "2", "Test Hook", "hook", brand="C"),
|
||||
GearIdentity("rf4db", "3", "Test Hook", "float"),
|
||||
]
|
||||
rows = suggest_gear_crosswalk(canonical, identities)
|
||||
assert [row.status for row in rows] == ["ambiguous", "unmatched", "unmatched"]
|
||||
assert all(row.canonical_keys == () for row in rows)
|
||||
|
||||
|
||||
def test_gear_crosswalk_rejects_invalid_canonical_category() -> None:
|
||||
with pytest.raises(ValueError, match="invalid canonical gear category"):
|
||||
suggest_gear_crosswalk([CanonicalGear("bad", "Bad", "equipment")], [])
|
||||
Reference in New Issue
Block a user