feat(ota): support forced firmware dispatch
This commit is contained in:
@@ -24,10 +24,22 @@ async def test_device_info_report_persists_metadata_and_periodic_location(monkey
|
||||
calls.append(("location", kwargs))
|
||||
return {"device_id": kwargs["device_id"], "lat": kwargs["latitude"], "lng": kwargs["longitude"]}
|
||||
|
||||
async def fake_maybe_dispatch_forced_update(**kwargs):
|
||||
del kwargs
|
||||
return None
|
||||
|
||||
async def fake_get_setting_by_device_id(device_id):
|
||||
return {"device_id": device_id, "device_type": 2, "ota_channel": None}
|
||||
|
||||
monkeypatch.setattr(service, "_publish", fake_publish)
|
||||
monkeypatch.setattr(service, "_schedule_persistence", fake_schedule_persistence)
|
||||
monkeypatch.setattr("handlers.mqtt_handler.device_setting_service.insert_or_update", fake_insert_or_update)
|
||||
monkeypatch.setattr("handlers.mqtt_handler.device_setting_service.get_setting_by_device_id", fake_get_setting_by_device_id)
|
||||
monkeypatch.setattr("handlers.mqtt_handler.location_service.report_mqtt_device_location", fake_report_mqtt_device_location)
|
||||
monkeypatch.setattr(
|
||||
"banban.service.device.device_service.maybe_dispatch_forced_update",
|
||||
fake_maybe_dispatch_forced_update,
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
"handlers.mqtt_handler.wechat_mp_notification_service.schedule_low_battery_notification",
|
||||
lambda **kwargs: None,
|
||||
@@ -103,9 +115,21 @@ async def test_device_info_report_without_location_does_not_write_location(monke
|
||||
async def fake_insert_or_update(**kwargs):
|
||||
calls.append(("settings", kwargs["device_type"]))
|
||||
|
||||
async def fake_maybe_dispatch_forced_update(**kwargs):
|
||||
del kwargs
|
||||
return None
|
||||
|
||||
async def fake_get_setting_by_device_id(device_id):
|
||||
return {"device_id": device_id, "device_type": 1, "ota_channel": None}
|
||||
|
||||
monkeypatch.setattr(service, "_publish", fake_publish)
|
||||
monkeypatch.setattr(service, "_schedule_persistence", fake_schedule_persistence)
|
||||
monkeypatch.setattr("handlers.mqtt_handler.device_setting_service.insert_or_update", fake_insert_or_update)
|
||||
monkeypatch.setattr("handlers.mqtt_handler.device_setting_service.get_setting_by_device_id", fake_get_setting_by_device_id)
|
||||
monkeypatch.setattr(
|
||||
"banban.service.device.device_service.maybe_dispatch_forced_update",
|
||||
fake_maybe_dispatch_forced_update,
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
"handlers.mqtt_handler.wechat_mp_notification_service.schedule_low_battery_notification",
|
||||
lambda **kwargs: None,
|
||||
|
||||
Reference in New Issue
Block a user