"""--one-per-slot and --region read one grouping of a pack. The slot pass put each core extra under every system of its profile. PicoDrive ranks its Mega CD BIOSes within sega-megacd. Spread across sega-megadrive, sega-32x and the rest, they shared a tier with unranked files, the tier was ruled undecidable, and the keep overrode the drop. """ from __future__ import annotations import tests from tests.sources import script_source import os import unittest from pathlib import Path REPO_ROOT = Path(__file__).resolve().parents[1] class SlotPassReadsTheRegionGrouping(unittest.TestCase): def test_ranked_mega_cd_alternatives_are_decided(self): if not (REPO_ROOT / "database.json").is_file(): self.skipTest("database.json not built") from packs import platformpack from model.database import load_database from model.profiles import load_emulator_profiles from model.platforms import load_platform_config previous = os.getcwd() os.chdir(REPO_ROOT) self.addCleanup(os.chdir, previous) db = load_database("database.json") profiles = load_emulator_profiles("emulators") config = load_platform_config("retroarch", "platforms") drops, _fallbacks, _undecided = platformpack._select_variants( config, config["systems"], "emulators", db, config.get("base_destination", ""), profiles, None, "full", regions=None, one_per_slot=True, ) names = {os.path.basename(d) for d in drops} for name in ("jp_mcd1_9111.bin", "eu_mcd1_9210.bin"): self.assertIn(name, names) def test_one_grouping_function(self): source = script_source("generate_pack.py") self.assertNotIn("def _pack_member_groups", source) class VariantGroupSpansSystems(unittest.TestCase): def test_us_request_withdraws_the_other_mega_cd_lists(self): """PicoDrive files US under sega-segacd and EU/JP under sega-megacd. find_bios (platform/libretro/libretro.c:1296) fills one slot from one of three lists. Grouped by system, sega-megacd had no US member and was kept whole as a fallback. """ if not (REPO_ROOT / "database.json").is_file(): self.skipTest("database.json not built") from packs import platformpack from model import region from model.database import load_database from model.profiles import load_emulator_profiles from model.platforms import load_platform_config previous = os.getcwd() os.chdir(REPO_ROOT) self.addCleanup(os.chdir, previous) db = load_database("database.json") profiles = load_emulator_profiles("emulators") config = load_platform_config("retroarch", "platforms") drops, _fallbacks, _undecided = platformpack._select_variants( config, config["systems"], "emulators", db, config.get("base_destination", ""), profiles, None, "full", regions=region.parse_requested("us"), one_per_slot=False, ) names = {os.path.basename(d) for d in drops} for name in ("jp_mcd1_9111.bin", "eu_mcd2_9306.bin"): self.assertIn(name, names) for name in ("us_scd2_9306.bin", "us_scd1_9210.bin"): self.assertNotIn(name, names) class AFrontendCheckSeparatesPacks(unittest.TestCase): """Two lists of the same files under different checks are two packs: a hash platform drops a file whose hash disagrees, an existence one ships it. The fingerprint read destination, sha1 and md5 only.""" def test_verification_mode_and_entry_fields_split_groups(self): import tempfile import yaml from model.platforms import _platform_config_cache from resolve.grouping import group_identical_platforms files = [{"name": "a.bin", "destination": "a.bin", "md5": "0" * 32}] with tempfile.TemporaryDirectory() as tmp: for name, mode, extra in (("one", "existence", {}), ("two", "md5", {}), ("three", "existence", {"required": False})): entry = {**files[0], **extra} Path(tmp, f"{name}.yml").write_text(yaml.dump({ "platform": name, "verification_mode": mode, "systems": {"s": {"files": [entry]}}, })) Path(tmp, "_registry.yml").write_text(yaml.dump({"platforms": {}})) _platform_config_cache.clear() self.addCleanup(_platform_config_cache.clear) groups = group_identical_platforms(["one", "two", "three"], tmp) self.assertEqual(sorted(g for g, _ in groups), [["one"], ["three"], ["two"]]) if __name__ == "__main__": unittest.main()