feat: checkpoint device agent runtime milestones
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from storage.device_config import DeviceConfigStore
|
||||
|
||||
|
||||
def test_device_config_store_add_remove_list_and_get(tmp_path) -> None:
|
||||
store = DeviceConfigStore(tmp_path / "device_config.sqlite3")
|
||||
|
||||
store.add(
|
||||
device_id="iphone-1",
|
||||
name="Desk iPhone",
|
||||
driver_type="wda",
|
||||
connection_info={"server_url": "http://127.0.0.1:4723", "udid": "abc123"},
|
||||
)
|
||||
store.add(
|
||||
device_id="iphone-2",
|
||||
name=None,
|
||||
driver_type="wda",
|
||||
connection_info={"wda_local_port": 8101},
|
||||
)
|
||||
|
||||
assert store.get("iphone-1") == {
|
||||
"device_id": "iphone-1",
|
||||
"name": "Desk iPhone",
|
||||
"driver_type": "wda",
|
||||
"connection_info": {
|
||||
"server_url": "http://127.0.0.1:4723",
|
||||
"udid": "abc123",
|
||||
},
|
||||
}
|
||||
assert [config["device_id"] for config in store.list()] == ["iphone-1", "iphone-2"]
|
||||
|
||||
store.remove("iphone-1")
|
||||
|
||||
assert store.get("iphone-1") is None
|
||||
assert [config["device_id"] for config in store.list()] == ["iphone-2"]
|
||||
|
||||
|
||||
def test_device_config_store_settings_get_set_and_defaults(tmp_path) -> None:
|
||||
store = DeviceConfigStore(tmp_path / "device_config.sqlite3")
|
||||
|
||||
assert store.get_setting("max_steps") == "20"
|
||||
assert store.get_setting("missing") is None
|
||||
|
||||
store.set_setting("max_steps", 30)
|
||||
store.set_setting("feature_flag", "enabled")
|
||||
|
||||
reopened = DeviceConfigStore(tmp_path / "device_config.sqlite3")
|
||||
assert reopened.get_setting("max_steps") == "30"
|
||||
assert reopened.get_setting("feature_flag") == "enabled"
|
||||
|
||||
|
||||
def test_device_config_store_unknown_device_remove_is_noop(tmp_path) -> None:
|
||||
store = DeviceConfigStore(tmp_path / "device_config.sqlite3")
|
||||
|
||||
store.remove("missing")
|
||||
|
||||
assert store.get("missing") is None
|
||||
Reference in New Issue
Block a user