fix(host-agent): load configured devices
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user