test: include realtime in production smoke
This commit is contained in:
@@ -78,6 +78,64 @@ class GoNativeProdSmokeTest(unittest.TestCase):
|
||||
self.assertIn("gb32960.daily_mileage", names)
|
||||
self.assertIn("jt808.daily_total_mileage", names)
|
||||
|
||||
def test_vehicle_identifier_prefers_vin_over_vehicle_key(self):
|
||||
identifier = smoke.vehicle_identifier({
|
||||
"vin": "LB9A32A20R0LS1343",
|
||||
"vehicle_key": "GB32960:ignored",
|
||||
})
|
||||
|
||||
self.assertEqual(identifier, "LB9A32A20R0LS1343")
|
||||
|
||||
def test_vehicle_identifier_falls_back_to_vehicle_key(self):
|
||||
identifier = smoke.vehicle_identifier({
|
||||
"vin": "",
|
||||
"vehicle_key": "JT808:013307811170",
|
||||
})
|
||||
|
||||
self.assertEqual(identifier, "JT808:013307811170")
|
||||
|
||||
def test_realtime_specs_are_built_from_raw_samples_with_vin(self):
|
||||
payloads = {
|
||||
"gb32960.raw": {"items": [{"vin": "LB9A32A20R0LS1343", "vehicle_key": "LB9A32A20R0LS1343"}]},
|
||||
"jt808.raw": {"items": [{"vin": "", "vehicle_key": "JT808:013307811170"}]},
|
||||
"yutong_mqtt.raw": {"items": [{"vin": "LMRKH9AC6R1004108"}]},
|
||||
}
|
||||
|
||||
specs = smoke.build_realtime_specs(payloads)
|
||||
|
||||
self.assertEqual(
|
||||
[(spec.name, spec.path) for spec in specs],
|
||||
[
|
||||
("gb32960.realtime", "/api/realtime/vehicles/LB9A32A20R0LS1343"),
|
||||
("gb32960.realtime_online", "/api/realtime/vehicles/LB9A32A20R0LS1343/online"),
|
||||
("gb32960.realtime_protocol", "/api/realtime/vehicles/LB9A32A20R0LS1343/protocols/GB32960"),
|
||||
("jt808.realtime", "/api/realtime/vehicles/JT808%3A013307811170"),
|
||||
("jt808.realtime_online", "/api/realtime/vehicles/JT808%3A013307811170/online"),
|
||||
("jt808.realtime_protocol", "/api/realtime/vehicles/JT808%3A013307811170/protocols/JT808"),
|
||||
("yutong_mqtt.realtime", "/api/realtime/vehicles/LMRKH9AC6R1004108"),
|
||||
("yutong_mqtt.realtime_online", "/api/realtime/vehicles/LMRKH9AC6R1004108/online"),
|
||||
("yutong_mqtt.realtime_protocol", "/api/realtime/vehicles/LMRKH9AC6R1004108/protocols/YUTONG_MQTT"),
|
||||
],
|
||||
)
|
||||
|
||||
def test_realtime_check_requires_online_true_when_field_exists(self):
|
||||
check = smoke.check_realtime(
|
||||
"gb32960.realtime_online",
|
||||
{"vin": "LB9A32A20R0LS1343", "online": True, "protocols": ["GB32960"]},
|
||||
)
|
||||
|
||||
self.assertEqual(check.status, "pass")
|
||||
self.assertEqual(check.count, 1)
|
||||
|
||||
def test_realtime_check_fails_when_online_false(self):
|
||||
check = smoke.check_realtime(
|
||||
"gb32960.realtime_online",
|
||||
{"vin": "LB9A32A20R0LS1343", "online": False},
|
||||
)
|
||||
|
||||
self.assertEqual(check.status, "fail")
|
||||
self.assertIn("online=false", check.message)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user