v3.23.6: the event name keywords in the test-script editor
A script's `event` value may be a code (a hex byte or a number) or one of the server's name keywords (location_status, access_tech, network_rejection, data_connection, ... - events.py's EVENT_NAMES); the API accepts both. The PWA parsed every value as a hex string: the step list showed 'EVENT 0xaccess_tech' (the unparsed fallback), the editor fell back to event 03 (Location status) with the location field set, and saving then rewrote the step to that event - silently corrupting name-authored scripts (the two Alfa2G trigger scripts use access_tech/data_connection). A mirrored EVENT_ALIASES map plus an eventCode() resolver (number / hex byte / name -> code) now feed the step summary, the editor's event block and the event check; the summary's fallback no longer prefixes a non-numeric value with 0x, and the editor keeps its canonical hex form on save (the same code). Drift guard: the aliases live in frontend/tests/event_vectors.json, asserted by the Node test (the PWA's map + resolver) and the Python test (events.EVENT_NAMES + resolve_event). Tests: 856 frontend + 839 Python; sw cache simple-v419.
This commit is contained in:
@@ -41,6 +41,16 @@ class EventVectorTests(unittest.TestCase):
|
||||
self.assertEqual(events.scts_bytes(stamp, v['tz_east_min']).hex().upper(),
|
||||
v['hex'])
|
||||
|
||||
def test_the_shared_event_name_aliases(self):
|
||||
# the script's `event` value may be one of these name keywords; the
|
||||
# PWA mirrors the map (frontend/tests/event_forms.test.js)
|
||||
want = {name: int(hexv, 16) for name, hexv in VECTORS['aliases'].items()}
|
||||
self.assertEqual(events.EVENT_NAMES, want)
|
||||
for name, code in want.items():
|
||||
self.assertEqual(events.resolve_event(name), code, name)
|
||||
self.assertEqual(events.resolve_event(hex(code)[2:].upper().zfill(2)), code)
|
||||
self.assertIsNone(events.resolve_event('nonsense'))
|
||||
|
||||
def test_the_host_clock_date_time_object(self):
|
||||
# the data-connection builder embeds the 8.39 object 26 07 ...
|
||||
out = events.build(0x1D, {'status': '0', 'type': '0', 'ti': '00',
|
||||
|
||||
Reference in New Issue
Block a user