mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-29 12:58:51 -06:00
refactor: one recipe rule, one reconstruction
This commit is contained in:
1 parent
41da592291
commit
b0b505dc94
4 files changed
+32
-67
No files matched your search
@@ -135,6 +135,18 @@ class PoolAndBuild(unittest.TestCase):
|
||||
self.assertEqual(found[0], "v1")
|
||||
self.assertEqual(hashlib.md5(found[1]).hexdigest(), target)
|
||||
|
||||
def test_reconstruct_selects_the_recipe_with_every_member(self):
|
||||
crc_a, crc_b = _crc(ROM_A), _crc(ROM_B)
|
||||
wanted = hashlib.md5(
|
||||
build_torrentzip([("a.rom", ROM_A), ("b.rom", ROM_B)])
|
||||
).hexdigest()
|
||||
recipes = {"v1": [("a.rom", crc_a)], "v2": [("a.rom", crc_a), ("b.rom", crc_b)]}
|
||||
self.assertEqual(reconstruct(wanted, recipes, self.pool)[0], "v2")
|
||||
self.assertIsNone(reconstruct("0" * 32, recipes, self.pool))
|
||||
|
||||
def test_reconstruct_skips_recipes_with_absent_atoms(self):
|
||||
self.assertIsNone(reconstruct("0" * 32, {"v1": [("a.rom", "ffffffff")]}, self.pool))
|
||||
|
||||
|
||||
class ReportsOverAFixture(unittest.TestCase):
|
||||
"""A whole run over a synthetic collection, database and platform."""
|
||||
|
||||
@@ -10,7 +10,7 @@ import tempfile
|
||||
import unittest
|
||||
import zipfile
|
||||
|
||||
from core.torrentzip import build_torrentzip, identify_romset, is_torrentzip, rebuild_torrentzip
|
||||
from core.torrentzip import build_torrentzip, is_torrentzip, rebuild_torrentzip
|
||||
|
||||
REPO_ROOT = os.path.join(os.path.dirname(__file__), "..")
|
||||
|
||||
@@ -114,30 +114,6 @@ class TorrentZipTest(unittest.TestCase):
|
||||
if not checked:
|
||||
self.skipTest("corrected romsets not present in this checkout")
|
||||
|
||||
def test_identify_romset_selects_matching_recipe(self):
|
||||
atoms = {"3610a686": b"alpha", "9d0d1b46": b"beta"}
|
||||
import zlib
|
||||
|
||||
atoms = {
|
||||
f"{zlib.crc32(b'alpha') & 0xffffffff:08x}": b"alpha",
|
||||
f"{zlib.crc32(b'beta') & 0xffffffff:08x}": b"beta",
|
||||
}
|
||||
crc_a, crc_b = list(atoms)
|
||||
wanted = hashlib.md5(
|
||||
build_torrentzip([("a.rom", b"alpha"), ("b.rom", b"beta")])
|
||||
).hexdigest()
|
||||
recipes = {
|
||||
"v1": [("a.rom", crc_a)],
|
||||
"v2": [("a.rom", crc_a), ("b.rom", crc_b)],
|
||||
}
|
||||
self.assertEqual(identify_romset(recipes, atoms, wanted), "v2")
|
||||
self.assertIsNone(identify_romset(recipes, atoms, "0" * 32))
|
||||
|
||||
def test_identify_romset_skips_recipes_with_absent_atoms(self):
|
||||
atoms = {"aaaaaaaa": b"x"}
|
||||
recipes = {"v1": [("a.rom", "ffffffff")]}
|
||||
self.assertIsNone(identify_romset(recipes, atoms, "0" * 32))
|
||||
|
||||
|
||||
def _as_file(test: unittest.TestCase, data: bytes) -> str:
|
||||
"""Write bytes to a temp file cleaned up with the test."""
|
||||
|
||||
Reference in new issue
Block a user