sorter: cross-system name adoption needs token containment; sys-retry keeps the higher score
This commit is contained in:
@@ -84,19 +84,43 @@ def test_prov_dir_rehome():
|
||||
def test_prov_weak_tier():
|
||||
"""Below-threshold dir hit is accepted as low confidence."""
|
||||
root = Path(tempfile.mkdtemp(prefix="sorter_test_src_"))
|
||||
pack = root / "Multi Pack"
|
||||
# 'guardian squad extras' scores below 1.0 but high vs 'Guardian Squad'
|
||||
write(pack / "guardian squad extras" / "g.stl")
|
||||
# pack name carries a keyword so the probe resolves system+faction -
|
||||
# only then does the same-faction weak tier apply
|
||||
pack = root / "Aeldari Pack"
|
||||
write(pack / "guardian weapon team" / "g.stl") # 0.59 vs Guardian Squad
|
||||
library = make_lib()
|
||||
items = prov_items(root, library)
|
||||
(root / "extract_manifest.jsonl").write_text(json.dumps({
|
||||
"archive": str(root / "Aeldari Pack.zip"),
|
||||
"dest": "Aeldari Pack", "unit": "Aeldari Pack.zip",
|
||||
}), encoding="utf-8")
|
||||
files = sorted((root / "Aeldari Pack").rglob("*"))
|
||||
items = sort_plan(files, library, get_catalog(), provenance={
|
||||
"Aeldari Pack": "Aeldari Pack.zip"}, root=root)
|
||||
it = next(i for i in items if i.name == "g.stl")
|
||||
assert it.match_kind in ("weak", "catalog"), it.match_kind
|
||||
if it.match_kind == "weak":
|
||||
assert it.confidence == "low"
|
||||
assert it.match_kind == "weak", (it.match_kind, it.confidence)
|
||||
assert it.confidence == "low"
|
||||
assert "Guardian" in str(it.target)
|
||||
shutil.rmtree(root); shutil.rmtree(library)
|
||||
|
||||
|
||||
def test_cross_system_needs_token_containment():
|
||||
"""'Aeldari Rangers' must not adopt Middle-earth 'Dwarf Rangers'."""
|
||||
root = Path(tempfile.mkdtemp(prefix="sorter_test_src_"))
|
||||
pack = root / "MQVxKzh" # hash name: system stays unknown
|
||||
write(pack / "Aeldari Rangers" / "Luminary - Arms - (1).stl")
|
||||
write(pack / "14 Warp spiders" / "sp.stl")
|
||||
library = make_lib()
|
||||
files = sorted((root / "MQVxKzh").rglob("*"))
|
||||
items = sort_plan(files, library, get_catalog(), provenance={
|
||||
"MQVxKzh": "MQVxKzh.zip"}, root=root)
|
||||
by_name = {i.name: i for i in items}
|
||||
lum = by_name["Luminary - Arms - (1).stl"]
|
||||
assert "Middle-Earth" not in str(lum.target), lum.target
|
||||
spider = by_name["sp.stl"]
|
||||
assert "Warp Spiders" in str(spider.target), spider.target
|
||||
shutil.rmtree(root); shutil.rmtree(library)
|
||||
|
||||
|
||||
def test_nonprov_rehome():
|
||||
"""Loose noise file inside a named dir re-homes to the dir's unit."""
|
||||
root = Path(tempfile.mkdtemp(prefix="sorter_test_src_"))
|
||||
@@ -140,7 +164,7 @@ def load_catalog_path():
|
||||
def main():
|
||||
catalog = load_catalog_path()
|
||||
for fn in (test_prov_dir_rehome, test_prov_weak_tier, test_nonprov_rehome,
|
||||
test_apply_weak_doc):
|
||||
test_cross_system_needs_token_containment, test_apply_weak_doc):
|
||||
fn()
|
||||
print("OK", fn.__name__)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user