"""`ackit verify --catalog`: the catalog in use against a fresh scan of the game.""" import glob import os from ackit.catalog import read_csv, write_csv from ackit.game import Game from ackit.paths import user_dir from ackit.verify import catalogcheck def test_clean_synthetic_catalog_passes(synth_game): root, _ = synth_game rep = catalogcheck.run(Game(root), log=lambda *a: None) assert rep.ok, rep.issues assert rep.checked["BANK"] == 6 and rep.checked["INT"] == 4 def test_corrupted_catalog_is_reported(synth_game): root, _ = synth_game game = Game(root) catalogcheck.run(game, ["INT", "BANK"], log=lambda *a: None) # builds the cached scans cache = glob.glob(os.path.join(user_dir("cache"), "scan_INT_*.csv"))[0] rows = read_csv(cache) rows[1].category = "Weapons" # wrong category rows.append(rows[0]) # duplicate del rows[2] # missing write_csv(cache, rows) bank = glob.glob(os.path.join(user_dir("cache"), "scan_BANK_*.csv"))[0] brows = read_csv(bank) brows[0].name = brows[1].name # duplicate name write_csv(bank, brows[:-1]) # one sound missing rep = catalogcheck.run(game, ["INT", "BANK"], log=lambda *a: None) kinds = {(a, k) for a, k, _, _ in rep.issues} assert {("INT", "category"), ("INT", "duplicate"), ("INT", "missing"), ("BANK", "duplicate"), ("BANK", "missing")} <= kinds def test_real_catalog_quick(real_game_dir): rep = catalogcheck.run(Game(real_game_dir), quick=True, log=lambda *a: None) assert rep.ok, rep.issues[:10]