test: add jt808 e2e smoke verifier
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
38
tools/test_jt808_e2e_smoke.py
Normal file
38
tools/test_jt808_e2e_smoke.py
Normal file
@@ -0,0 +1,38 @@
|
||||
import pathlib
|
||||
import unittest
|
||||
|
||||
from tools import jt808_e2e_smoke as smoke
|
||||
|
||||
|
||||
class Jt808E2ESmokeTest(unittest.TestCase):
|
||||
def test_build_frame_adds_boundaries_and_valid_checksum(self):
|
||||
body = smoke.build_location_body(smoke.parse_event_time("2024-01-02T03:04:05"))
|
||||
|
||||
frame = smoke.build_frame(0x0200, "13079961234", 1, body)
|
||||
|
||||
self.assertEqual(frame[0], 0x7E)
|
||||
self.assertEqual(frame[-1], 0x7E)
|
||||
unescaped = smoke.unescape_payload(frame[1:-1])
|
||||
self.assertEqual(smoke.bcc(unescaped), 0)
|
||||
|
||||
def test_next_page_params_include_cursor(self):
|
||||
params = smoke.next_page_params(
|
||||
{"phone": "13079961234", "limit": 1},
|
||||
{"nextCursor": {"ts": "2024-01-01T19:04:05Z", "id": "frame-1"}},
|
||||
)
|
||||
|
||||
self.assertEqual(params["cursorTs"], "2024-01-01T19:04:05Z")
|
||||
self.assertEqual(params["cursorId"], "frame-1")
|
||||
self.assertEqual(params["phone"], "13079961234")
|
||||
|
||||
def test_archive_path_maps_archive_uri_to_root(self):
|
||||
path = smoke.archive_path(
|
||||
pathlib.Path("/tmp/archive"),
|
||||
"archive://2026/06/29/JT808/unknown/frame.bin",
|
||||
)
|
||||
|
||||
self.assertEqual(path, pathlib.Path("/tmp/archive/2026/06/29/JT808/unknown/frame.bin"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user