fix(host-agent): load configured devices

This commit is contained in:
2026-07-13 07:56:41 +08:00
parent dbd70732e1
commit 90961bd0a4
5 changed files with 56 additions and 1 deletions
+27
View File
@@ -8,6 +8,7 @@ from cloud.internal_api.models import AssignmentModel
from device.manager import DeviceManager
from host_agent.app import HostAgentApplication, create_application
from host_agent.config import HostAgentConfig
from storage.device_config import DeviceConfigStore
def _config() -> HostAgentConfig:
@@ -38,6 +39,32 @@ def test_create_application_composes_host_agent_services(tmp_path, monkeypatch)
asyncio.run(application.client.aclose())
def test_create_application_loads_persisted_device_configuration(
tmp_path,
monkeypatch,
) -> None:
monkeypatch.chdir(tmp_path)
store = DeviceConfigStore(tmp_path / "devices.sqlite3")
store.add(
device_id="device-a",
name="Lab iPhone",
driver_type="wda",
connection_info={"url": "http://wda.local"},
)
application = create_application(
config=_config(),
device_config_store=store,
)
devices = application.heartbeat.manager.list_devices()
assert [(device.id, device.name, device.driver_type) for device in devices] == [
("device-a", "Lab iPhone", "wda")
]
assert devices[0].connection_info == {"url": "http://wda.local"}
asyncio.run(application.client.aclose())
def test_shutdown_cancels_long_poll_and_sends_final_heartbeat() -> None:
async def scenario() -> None:
claim_started = asyncio.Event()