fix: prevent tdengine raw frame overwrite
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:
35
tools/test_tdengine_smoke.py
Normal file
35
tools/test_tdengine_smoke.py
Normal file
@@ -0,0 +1,35 @@
|
||||
import unittest
|
||||
|
||||
from tools import tdengine_smoke
|
||||
|
||||
|
||||
class TdengineSmokeTest(unittest.TestCase):
|
||||
def test_sql_literal_escapes_single_quotes(self):
|
||||
self.assertEqual(tdengine_smoke.sql_literal("VIN'001"), "'VIN''001'")
|
||||
|
||||
def test_raw_frame_count_sql_filters_by_protocol_vehicle_and_raw_uri(self):
|
||||
sql = tdengine_smoke.raw_frame_count_sql(
|
||||
protocol="JT808",
|
||||
vehicle_key="jt808:13079962000",
|
||||
raw_uri="archive://2026/06/29/JT808/frame.bin",
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
sql,
|
||||
"SELECT COUNT(*) FROM raw_frames WHERE protocol = 'JT808' "
|
||||
"AND vehicle_key = 'jt808:13079962000' "
|
||||
"AND raw_uri = 'archive://2026/06/29/JT808/frame.bin'",
|
||||
)
|
||||
|
||||
def test_raw_frame_count_sql_requires_at_least_one_identity_or_raw_uri_filter(self):
|
||||
with self.assertRaises(ValueError):
|
||||
tdengine_smoke.raw_frame_count_sql(protocol="GB32960")
|
||||
|
||||
def test_count_from_response_reads_first_cell(self):
|
||||
response = {"code": 0, "data": [[3]], "rows": 1}
|
||||
|
||||
self.assertEqual(tdengine_smoke.count_from_response(response), 3)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user