import hashlib import json from ams.inventory import inventory def test_inventory_hashes_actual_bytes_and_preserves_aliases(tmp_path): (tmp_path / "Game__falsehash__PIKLIB8.DLL").write_bytes(b"same") (tmp_path / "Other__falsehash__PIKLIB8.DLL").write_bytes(b"same") (tmp_path / "Game__falsehash__PIKLIB61.DLL").write_bytes(b"different") (tmp_path / "Game [piklib72]__falsehash__SEKAI.DLL").write_bytes(b"sekai") (tmp_path / "PIKLIB41.DLL").write_bytes(b"old") sha = hashlib.sha256(b"same").hexdigest() (tmp_path / "test.snapshot.json").write_text(json.dumps({"binary":{"sha256":sha}})) result = inventory([tmp_path],tmp_path) assert result["summary"] == {"files":5,"unique":4,"by_scope":{"engine":2,"native_dependency":1,"excluded_early_engine":1}} same = next(b for b in result["builds"] if b["sha256"] == sha) assert len(same["paths"]) == 2 assert same["analysis"] == "snapshot_available" assert same["suggested_snapshot"] == sha + ".snapshot.json"