Files
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

35 lines
1.5 KiB
Python

import os, sys, unittest
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
sys.path.insert(0, os.path.join(ROOT, "scripts"))
from update_swarm.versions import compare_versions, normalize_version
class TestNormalize(unittest.TestCase):
def test_strips_v_and_language_tag(self):
self.assertEqual(normalize_version("v2.13 (EN)"), "2.13")
self.assertEqual(normalize_version("V1.0.4.2"), "1.0.4.2")
self.assertEqual(normalize_version("2.18 (ES)"), "2.18")
class TestCompare(unittest.TestCase):
def test_numeric_order(self):
self.assertEqual(compare_versions("1.0.3", "1.0.4.2"), "lt")
self.assertEqual(compare_versions("v1.0.4.2", "1.0.3"), "gt")
self.assertEqual(compare_versions("v2.13 (EN)", "2.13"), "eq")
self.assertEqual(compare_versions("4.1", "4.10"), "lt")
def test_incomparable_non_numeric(self):
self.assertEqual(compare_versions("Final", "1.2"), "incomparable")
self.assertEqual(compare_versions("2026-03-30", "Nightly"), "incomparable")
def test_dates_are_incomparable(self):
self.assertEqual(compare_versions("2026-03-30", "2026-04-01"), "incomparable")
self.assertEqual(compare_versions("2026-03-30", "1.2"), "incomparable")
def test_hotfix_suffix_is_incomparable(self):
self.assertEqual(compare_versions("1.0.2 Hotfix", "1.0.2"), "incomparable")
def test_equal_non_numeric_after_normalize(self):
self.assertEqual(compare_versions("Final", "final"), "eq")
if __name__ == "__main__":
unittest.main()