fix: show exact sizes where the code compares them

A size validated by the emulator is shown with its bytes on the emulator
page, and a collection card's badge gives the exact size, in whole KB or
MB only when it is one. raze's three DUKE3D.GRP read 42.3 MB alike.
This commit is contained in:
Abdessamad Derraz committed 2026-11-06 03:44:57 +01:00
1 parent 6d6a79019a
commit 225cdaff22
4 files changed
+62 -8

No files matched your search

+1 -1
View File
@@ -110,7 +110,7 @@ class ASystemCardShowsTheAnswerFirst(unittest.TestCase):
self.shown = self.text.replace(self.fold, "")
def test_the_open_part(self) -> None:
for fact in ("<code>ppge_atlas.zim</code>", ">650.9 KB<", ">Download</a>",
for fact in ("<code>ppge_atlas.zim</code>", ">666,539 B<", ">Download</a>",
"<dt>On the setup's list</dt>", "<dt>Packed for its emulators by</dt>",
"<dt>Emulators</dt>", f'<dt>SHA1</dt><dd class="rb-hash">{SHA1[:12]}</dd>'):
self.assertIn(fact, self.shown)
+16
View File
@@ -789,6 +789,22 @@ class AnEmulatorPageNamesItsSetups(unittest.TestCase):
self.assertIn("EmuDeck", card[1].splitlines()[0])
class SizesTheCodeComparesAreExact(unittest.TestCase):
"""raze validates DUKE3D.GRP by size, and its page showed 42.3 MB for
44,356,548 and 44,348,015 bytes alike."""
def test_a_validated_size_carries_its_bytes(self):
profile = {"emulator": "x", "type": "libretro", "systems": ["sony-playstation"], "files": [
{"name": "DUKE3D.GRP", "size": 44348015, "validation": ["size", "crc32"]},
{"name": "other.bin", "size": 44356548},
{"name": "built.bin", "size": 2304, "validation": {"core": ["size"]}},
]}
page = _page("x", profile)
self.assertIn("Size: 42.3 MB (44,348,015 bytes)", page)
self.assertIn("Size: 2.2 KB (2,304 bytes)", page)
self.assertNotIn("44,356,548", page)
class ADataDirectoryNamesAFetchableOrigin(unittest.TestCase):
"""pcee2's page linked github.com/PCSX2/pcsx2/archive/{version}.tar.gz,
a 404, and buildbot zips showed `Revision: master (2047720058)`: a branch
+13
View File
@@ -184,6 +184,19 @@ class ThePermalinkIsAnIcon(unittest.TestCase):
self.assertEqual(page.count('href="#rb-link-icon"'), 2)
class TheCardGivesTheSizeInBytes(unittest.TestCase):
"""The badge rounded to 0.1 KB and no line of a system card gave the
bytes an emulator compares."""
def test_the_badge_is_exact(self):
for size, shown in ((524288, "512 KB"), (44348015, "44,348,015 B"),
(2 * 1024 * 1024, "2 MB"), (2304, "2,304 B"), (10, "10 B")):
with self.subTest(size=size):
card = {**_sony_file("scph5501.bin", "4"), "size": size}
title = gs._system_file_card(card, FileConsumers({"files": {}}))[2]
self.assertIn(f'<span class="rb-badge rb-badge-muted">{shown}</span>', title)
class TheCardLinesSayWhatTheyMean(unittest.TestCase):
""""Platforms:" and "Also installed by:" listed different setups, as
lower-case ids, and only a code comment told them apart."""