v3.32.1: "Start counter value" in the outfile import
release / release (push) Has been cancelled

The import created presets with the store's default counter (1).  Cards
whose counters are already past it had to be edited preset by preset
afterwards.

- The outfile preview form gains a "Start counter value" field (default
  1, the store's value).  The value is written into every created keyset
  of every imported card - parse_outfile's `start_counter`, 1-10 hex
  digits, whitespace stripped and uppercased; a bad value raises and the
  endpoint answers 400.  Without it the store's default still applies
  (the field is omitted), so the API keeps its old behaviour.
- The preview shows the counter; an import stores the protocol's
  10-digit form (counter_hex).
- Docs: api.md (the field), help EN/RU (the form).
- Version strings + the PWA cache bumped together (simple-v459).

Tests: the parser (every keyset, normalisation, unset, the bad values),
the endpoint (the preview's keysets, the 400, the stored padded form),
the PWA (the field's default, the controls' normalisation, both bodies).
1008 Python + 953 frontend green.
This commit is contained in:
2026-10-21 13:20:28 +03:00
parent aa8c9c6f12
commit cdd3820064
12 changed files with 101 additions and 18 deletions
+20
View File
@@ -979,6 +979,26 @@ class PresetStoreHttpTests(unittest.TestCase):
self.assertEqual(status, 400, resp)
self.assertIn('the file is invalid', resp['error'])
self.assertEqual(len(self.store.list()), before)
# the import form's start counter (v3.32.1): every created keyset
# carries it; an unusable value is a 400
status, resp = self._post('/api/presets/import-outfile', {
'text': text, 'start_counter': '1A'})
self.assertEqual(status, 200, resp)
self.assertEqual([k.get('cntr') for k in resp['presets'][0]['keysets']],
['1A'] * len(resp['presets'][0]['keysets']))
status, resp = self._post('/api/presets/import-outfile', {
'text': text, 'start_counter': 'XYZ'})
self.assertEqual(status, 400, resp)
self.assertIn('start_counter', resp['error'])
# ...and an import stores the protocol's padded form (a fresh ICCID:
# merge mode skips a duplicate)
fresh = text.replace('8970119000004600098', '8970119000004600999')
status, resp = self._post('/api/presets/import-outfile', {
'text': fresh, 'start_counter': '1A', 'mode': 'merge'})
self.assertEqual(status, 200, resp)
got = [p for p in self.store.list()
if p['iccid'] == '8970119000004600999']
self.assertEqual([k['cntr'] for k in got[0]['keysets']], ['000000001A'])
# a non-list TAR table is the caller's error, never a silent fallback
status, resp = self._post('/api/presets/import-outfile', {
'text': text, 'tars': 'nope'})