fix: never pair files whose contents or dirs differ

This commit is contained in:
Abdessamad Derraz committed 2026-10-06 12:15:40 +02:00
1 parent e476758f73
commit ecdfbdf64f
4 files changed
+75 -3

No files matched your search

+35
View File
@@ -195,6 +195,16 @@ class MisterCountsWhatItWrites(unittest.TestCase):
self.assertFalse(exporter.states(absent, "md5"))
class OneMd5FormatsAddWhole(unittest.TestCase):
def test_an_addition_with_several_md5_is_refused(self):
from exporter.batocera_exporter import Exporter as Batocera # noqa: PLC0415
several = NativeFile("boot.bin", "boot.bin", "dc", truth={"md5": [A, B, C]})
single = NativeFile("boot2.bin", "boot2.bin", "dc", truth={"md5": A})
self.assertFalse(Batocera.writable(several))
self.assertTrue(Batocera.writable(single))
class ModelKeepsOneFileOneEntry(unittest.TestCase):
def test_a_list_of_sizes_is_not_one_size(self):
"""A profile may accept several revisions; int() on the list crashed."""
@@ -275,6 +285,31 @@ class RommKeepsItsOwnKeys(unittest.TestCase):
self.assertEqual(written["dc:boot.bin"]["size"], "2097152")
self.assertFalse(exporter.writable(ours))
class NamesInAnotherDirectory(unittest.TestCase):
def test_a_truth_path_in_another_directory_does_not_match(self):
scraped = {"systems": {"pc98": {"files": [
{"name": "bios.rom", "destination": "np2kai/bios.rom", "md5": A},
]}}}
truth = {"systems": {"pc98": {"files": [
{"name": "bios.rom", "path": "BeebFile/BIOS.rom", "md5": B},
]}}}
systems, _report = build_native_model(truth, scraped)
declared = next(f for f in systems["pc98"].files if f.platform is not None)
self.assertIsNone(declared.truth)
def test_a_destination_ending_in_the_path_matches(self):
scraped = {"systems": {"gc": {"files": [
{"name": "IPL.bin", "destination": "dolphin-emu/Sys/GC/USA/IPL.bin", "md5": A},
{"name": "IPL.bin", "destination": "dolphin-emu/Sys/GC/EUR/IPL.bin", "md5": B},
]}}}
truth = {"systems": {"gc": {"files": [
{"name": "IPL.bin", "path": "GC/EUR/IPL.bin", "md5": B},
{"name": "IPL.bin", "path": "GC/USA/IPL.bin", "md5": A},
]}}}
systems, report = build_native_model(truth, scraped)
self.assertEqual(report.hashes_corrected, [])
class RecalboxKeepsItsOwnNotes(unittest.TestCase):
def test_no_profile_prose_reaches_a_note(self):
fe = NativeFile("bios.bin", "bios.bin", "psx", platform={"md5": A},
+11
View File
@@ -115,6 +115,17 @@ class OneNameSeveralFiles(unittest.TestCase):
self.assertEqual(_diff_system(self._system(), scraped), {})
class DifferentContentsStayApart(unittest.TestCase):
def test_two_cores_same_name_different_contents(self):
"""beebem's BBC BIOS.rom and np2kai's PC-98 bios.rom merged into one."""
system: dict = {}
_merge_file_into_system(system, {"name": "bios.rom", "path": "np2kai/bios.rom",
"md5": "a" * 32}, "np2kai", None)
_merge_file_into_system(system, {"name": "bios.rom", "path": "BeebFile/BIOS.rom",
"md5": "b" * 32, "size": 16384}, "beebem", None)
self.assertEqual(len(system["files"]), 2)
class RenameMatching(unittest.TestCase):
def test_a_shared_sha1_pairs_the_two_names(self):
truth = [_entry("bios_CD_U.bin", sha1="a" * 40)]