fix: name where a held profile entry sits

164 entries wore the in repo badge with no copy named: they are held as
a ZIP member or in a data directory, which the database does not index.
held_copy() finds that copy and the card names it. storage: large_file
no longer counts as held by itself: kenji-nx's user-picked firmware
package read as held although nothing collects it.
This commit is contained in:
Abdessamad Derraz committed 2026-10-21 10:02:50 +02:00
1 parent 45db77cfd0
commit e65ece743d
4 files changed
+158 -27

No files matched your search

+52
View File
@@ -33,6 +33,13 @@ class UnsourceableIsNotHeld(unittest.TestCase):
self.assertTrue(available({"name": "pak0.pk3"}))
self.assertFalse(available({"name": "pak0.pk3", "unsourceable": "retail data"}))
def test_a_release_asset_is_held_only_when_collected(self):
"""storage: large_file said "in repo" for kenji-nx's user-picked
firmware package, which the collection does not hold."""
available = _availability_check(DB, set())
self.assertFalse(available({"name": "<firmware>.zip", "storage": "large_file"}))
self.assertTrue(available({"name": "pak0.pk3", "storage": "release"}))
def test_the_badge_says_why(self):
entry = {"name": "pak0.pk3", "unsourceable": "retail data"}
badges = " ".join(_file_badges(entry, False))
@@ -57,5 +64,50 @@ class UnsourceableIsNotHeld(unittest.TestCase):
self.assertEqual(shown_held, [])
class AHeldEntrySaysWhere(unittest.TestCase):
"""164 entries wore the "in repo" badge with no copy named: they are held
as a ZIP member (zesarux's specmate.rom in spectrum_opus.zip) or in a
data directory (Dolphin's fonts), which the database does not index."""
def test_member_file_and_tree(self):
import hashlib
import tempfile
import zipfile
import generate_site
from cross_reference import FileConsumers, held_copy
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
data, bios = Path(tmp) / "data", Path(tmp) / "bios"
(data / "dolphin-sys" / "GC").mkdir(parents=True)
(data / "dolphin-sys" / "GC" / "font_western.bin").write_bytes(b"font")
(bios / "Arcade" / "MAME").mkdir(parents=True)
archive = bios / "Arcade" / "MAME" / "spectrum_opus.zip"
with zipfile.ZipFile(archive, "w") as zf:
zf.writestr("specmate.rom", b"rom")
roots = {"data_root": str(data), "bios_root": str(bios)}
member = held_copy({"name": "specmate.rom",
"sha1": hashlib.sha1(b"rom").hexdigest()}, **roots)
self.assertEqual(member, (str(archive), "specmate.rom"))
# A declared hash the copy does not carry names no copy.
self.assertIsNone(held_copy({"name": "specmate.rom", "sha1": "0" * 40}, **roots))
self.assertEqual(held_copy({"name": "font_western.bin"}, **roots),
(str(data / "dolphin-sys/GC/font_western.bin"), ""))
self.assertEqual(held_copy({"name": "GC/", "type": "directory"}, **roots),
(f"{(data / 'dolphin-sys/GC').as_posix()}/", ""))
consumers = FileConsumers({"files": {"z" * 40: {
"path": "bios/Arcade/MAME/spectrum_opus.zip"}}}, data_dir_registry={})
line = generate_site._held_copy_line(
("bios/Arcade/MAME/spectrum_opus.zip", "specmate.rom"), consumers)
self.assertEqual(line, "Collection copy: member `specmate.rom` of "
"[`bios/Arcade/MAME/spectrum_opus.zip`]"
"(../systems/arcade.md#sha1-zzzzzzzzzzzz)")
line = generate_site._held_copy_line(("data/dolphin-sys/GC/font_western.bin", ""),
consumers)
self.assertEqual(line, "Collection copy: `GC/font_western.bin` in the "
"`dolphin-sys` data directory")
if __name__ == "__main__":
unittest.main()