v3.12.0: the card preset carries the card's CAT (USAT) release

The release selector lives in the preset rather than a global chip: presets
already travel with the card (ICCID auto-selection, export/import), and the
operations that will consume the release are preset-aware.

- presets.py: the optional `release` field (4-18; empty = unspecified) joins
  PRESET_FIELDS; a value outside 4-18 is refused on save/import; the store
  schema version is 5.
- catrelease.py: DEFAULT_RELEASE = 12 and preset_release() - the effective
  release is the preset's own value, else Rel-12 (the safe level for cards
  whose release is not known; an unset release never filters anything away).
  The PWA mirrors both (CAT_RELEASE_DEFAULT + presetRelease()), drift-guarded.
- Cards tab: the editor's header row gains a compact CAT release select
  (unspecified / pre-Rel-6 stored as 5 / Rel-6 ... Rel-18); the empty option
  names the Rel-12 default and the tooltip explains the guard; the field is
  collected, cleared and restored with the other form fields.
- Nothing filters yet: the Simulator's event parameters (stage 3) will use
  the effective release.
- docs/api.md + help EN/RU updated; sw cache simple-v368.
This commit is contained in:
2026-10-02 11:28:33 +03:00
parent 2bb1528ca9
commit 3660a7e173
13 changed files with 149 additions and 13 deletions
+15 -1
View File
@@ -21,7 +21,7 @@ class TestCatReleaseTable(unittest.TestCase):
def test_pwa_mirror_matches_the_module(self):
# the PWA's release guard uses the same table (drift guard, like
# ETSI_TOOLKIT_RELEASE in test_cap_memory)
block, _ = _pwa_block()
block, html = _pwa_block()
ev = re.search(r"events:\s*\{(.*?)\}", block, re.S)
self.assertIsNotNone(ev, 'events section not found')
self.assertEqual(
@@ -34,6 +34,9 @@ class TestCatReleaseTable(unittest.TestCase):
self.assertEqual(
{k: int(v) for k, v in re.findall(r"'([^']+)':\s*(\d+)", m.group(1))},
catrelease.CAT_RELEASE[section], section)
d = re.search(r"const CAT_RELEASE_DEFAULT = (\d+);", html)
self.assertIsNotNone(d, 'CAT_RELEASE_DEFAULT not found in index.html')
self.assertEqual(int(d.group(1)), catrelease.DEFAULT_RELEASE)
def test_events_cover_the_pwa_event_list(self):
# every event the UI names through 0x1F except the Void 0x1A carries
@@ -60,6 +63,17 @@ class TestCatReleaseTable(unittest.TestCase):
self.assertIsNone(catrelease.item_release('events', 0x1A))
self.assertIsNone(catrelease.item_release('nope', 'x'))
def test_preset_release_resolves_the_default(self):
self.assertEqual(catrelease.DEFAULT_RELEASE, 12)
self.assertEqual(catrelease.preset_release({'release': '14'}), 14)
self.assertEqual(catrelease.preset_release({'release': 4}), 4)
self.assertEqual(catrelease.preset_release({'release': '18'}), 18)
# an unset or invalid release must never filter anything away
for p in ({}, {'release': ''}, {'release': '0'}, {'release': '3'},
{'release': '99'}, {'release': 'x'}, None):
self.assertEqual(catrelease.preset_release(p),
catrelease.DEFAULT_RELEASE, p)
def test_table_sanity(self):
for section, table in catrelease.CAT_RELEASE.items():
self.assertTrue(table, section)