feat: librarian helpers for superseded names, note patch, scoped RomM scan
This commit is contained in:
1 parent
dd62312f87
commit
5445f82d91
2 files changed
+85
No files matched your search
@@ -0,0 +1,43 @@
|
||||
import os, sys, tempfile, unittest
|
||||
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
|
||||
sys.path.insert(0, os.path.join(ROOT, "scripts"))
|
||||
from update_swarm.librarian import patch_note, require_platform_id, romm_scan_argv, superseded_name
|
||||
|
||||
class TestLibrarian(unittest.TestCase):
|
||||
def test_superseded_name(self):
|
||||
self.assertEqual(
|
||||
superseded_name("Pokemon - Z [Hack].zip", "v2.16 ES"),
|
||||
"Pokemon - Z [Hack] (v2.16 ES).zip",
|
||||
)
|
||||
|
||||
def test_romm_requires_platform_ids(self):
|
||||
argv = romm_scan_argv([72, 200])
|
||||
joined = " ".join(argv)
|
||||
self.assertIn("platform_ids=[72,200]", joined.replace(" ", ""))
|
||||
with self.assertRaises(ValueError):
|
||||
romm_scan_argv([])
|
||||
self.assertEqual(require_platform_id("GBA"), 72)
|
||||
self.assertEqual(require_platform_id("PC"), 200)
|
||||
with self.assertRaises(KeyError):
|
||||
require_platform_id("GameCube")
|
||||
|
||||
def test_patch_note_version_and_history(self):
|
||||
src = (
|
||||
"---\n"
|
||||
'title: "Pokémon Z"\n'
|
||||
'version: "2.17"\n'
|
||||
"status: Complete\n"
|
||||
"---\n\n"
|
||||
"## Summary\n\nKeep me.\n"
|
||||
)
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
path = os.path.join(td, "Z.md")
|
||||
open(path, "w", encoding="utf-8").write(src)
|
||||
text = patch_note(path, "v2.13 (EN)", "2026-03-30", "https://example.com/z", "- EN 2.13\n", None)
|
||||
self.assertIn('version: "v2.13 (EN)"', text)
|
||||
self.assertIn("## Version history", text)
|
||||
self.assertIn("## Summary\n\nKeep me.", text)
|
||||
self.assertNotIn("**bold**", text.split("## Summary")[1].split("##")[0])
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user