Files
pokemon/tests/update_swarm/test_jobs.py
T
ginnoir cb294f72a0 fix: address whole-branch review findings for update-swarm
- versions: require entire normalized string to be numeric so dates
  and hotfix suffixes compare as incomparable instead of eq/gt
- hosts: exact host or dot-suffix match rejects lookalikes like
  notmediafire.com and evilmega.nz; GitHub stays exact-set
- census: lazy extractor loop so a later OSError no longer discards an
  earlier sidecar changelog hit
- jobs: watchlist parses only table rows whose vault-note cell is a
  bare wikilink (skips parenthetical related/complete notes); wanted
  also matches bold names in Wanted.md tables with Pokemon prefix
  stripped and casefolded
- cli: validate-scouts and judge raise SystemExit when jobs.json has
  jobs but scouts/ has zero valid files
- fetch: download forwards timeout=60 to urlopen and writes to a
  .part file then os.replace, removing the partial on any failure
2026-08-14 15:11:16 -05:00

40 lines
1.8 KiB
Python

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.jobs import build_jobs, init_run
FIXTURE = os.path.join(os.path.dirname(__file__), "fixtures", "vault", "Pokémon ROM Hacks")
class TestJobs(unittest.TestCase):
def test_flags_watchlist_and_wanted(self):
jobs = {j["stem"]: j for j in build_jobs(FIXTURE)}
self.assertIn("FakeHack", jobs)
self.assertTrue(jobs["FakeHack"]["wanted"])
self.assertFalse(jobs["FakeHack"]["watchlist"])
self.assertEqual(jobs["FakeHack"]["note_version"], "1.0.0")
self.assertTrue(jobs["DemoOnly"]["watchlist"])
self.assertTrue(jobs["DemoOnly"]["wanted"])
self.assertIsNone(jobs["DemoOnly"]["library_path"])
def test_watchlist_skips_parenthetical_notes(self):
jobs = {j["stem"]: j for j in build_jobs(FIXTURE)}
# `[[Odyssey]] (related)` and `[[Light Platinum]] (GBA complete; DS is separate)`
# appear in Demo Watchlist table rows but are parenthetical notes, not watchlist stems.
self.assertFalse(jobs["Odyssey"]["watchlist"])
self.assertFalse(jobs["Light Platinum"]["watchlist"])
def test_wanted_matches_bold_names(self):
jobs = {j["stem"]: j for j in build_jobs(FIXTURE)}
# `**DemoOnly**` in Wanted.md (no wikilink) should still flag wanted.
self.assertTrue(jobs["DemoOnly"]["wanted"])
def test_init_run_creates_dirs(self):
with tempfile.TemporaryDirectory() as td:
run = os.path.join(td, "2026-08-14")
init_run(run)
for name in ("census", "scouts", "staging"):
self.assertTrue(os.path.isdir(os.path.join(run, name)))
if __name__ == "__main__":
unittest.main()