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
This commit is contained in:
ginnoir committed 2026-08-14 15:11:16 -05:00
1 parent 37ebc97b51
commit cb294f72a0
16 files changed
+234 -48

No files matched your search

+36 -1
View File
@@ -1,8 +1,9 @@
import json, 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.cli import deploy_argv, validate_scout
from update_swarm.cli import deploy_argv, validate_scout, main
from update_swarm.reports import write_reports
from update_swarm.schema import write_json
class TestCli(unittest.TestCase):
def test_validate_scout_missing_keys(self):
@@ -41,5 +42,39 @@ class TestCli(unittest.TestCase):
self.assertIn("latest_english_version", text)
self.assertIn("Do not invent versions", text)
def _valid_scout(self, stem):
return {
"stem": stem, "latest_english_version": "1.0", "url": "https://example.com/z.zip",
"host": "other", "gate": "gated", "language_matrix": {"en": "1.0"},
"source_used": "website", "hackdex": "skipped", "upstream_status": "Complete", "notes": "",
}
def test_validate_scouts_fails_when_jobs_but_no_scouts(self):
with tempfile.TemporaryDirectory() as td:
run = os.path.join(td, "2026-08-14")
os.makedirs(os.path.join(run, "scouts"))
write_json(os.path.join(run, "jobs.json"),
{"run_date": "2026-08-14", "jobs": [{"stem": "X"}]})
with self.assertRaises(SystemExit):
main(["--run", run, "validate-scouts"])
def test_validate_scouts_ok_when_scouts_present(self):
with tempfile.TemporaryDirectory() as td:
run = os.path.join(td, "2026-08-14")
scouts = os.path.join(run, "scouts")
os.makedirs(scouts)
write_json(os.path.join(run, "jobs.json"),
{"run_date": "2026-08-14", "jobs": [{"stem": "X"}]})
write_json(os.path.join(scouts, "X.json"), self._valid_scout("X"))
self.assertEqual(main(["--run", run, "validate-scouts"]), 0)
def test_validate_scouts_ok_when_no_jobs(self):
with tempfile.TemporaryDirectory() as td:
run = os.path.join(td, "2026-08-14")
os.makedirs(os.path.join(run, "scouts"))
write_json(os.path.join(run, "jobs.json"),
{"run_date": "2026-08-14", "jobs": []})
self.assertEqual(main(["--run", run, "validate-scouts"]), 0)
if __name__ == "__main__":
unittest.main()