47 lines
1.4 KiB
Python
47 lines
1.4 KiB
Python
from ria_toolkit_oss.agent import hardware
|
|
from ria_toolkit_oss.sdr import detect_available
|
|
|
|
|
|
def test_detect_available_includes_mock():
|
|
drivers = detect_available()
|
|
assert "mock" in drivers
|
|
from ria_toolkit_oss.sdr.mock import MockSDR
|
|
|
|
assert drivers["mock"] is MockSDR
|
|
|
|
|
|
def test_available_devices_sorted_list():
|
|
devices = hardware.available_devices()
|
|
assert isinstance(devices, list)
|
|
assert devices == sorted(devices)
|
|
assert "mock" in devices
|
|
|
|
|
|
def test_heartbeat_payload_shape():
|
|
p = hardware.heartbeat_payload()
|
|
assert p["type"] == "heartbeat"
|
|
assert p["status"] == "idle"
|
|
assert "mock" in p["hardware"]
|
|
assert "app_id" not in p
|
|
# New fields, default shape
|
|
assert p["capabilities"] == ["rx"]
|
|
assert p["tx_enabled"] is False
|
|
|
|
p2 = hardware.heartbeat_payload(status="streaming", app_id="abc")
|
|
assert p2["status"] == "streaming"
|
|
assert p2["app_id"] == "abc"
|
|
|
|
|
|
def test_heartbeat_payload_tx_capability_from_cfg():
|
|
from ria_toolkit_oss.agent.config import AgentConfig
|
|
|
|
p = hardware.heartbeat_payload(cfg=AgentConfig(tx_enabled=True))
|
|
assert p["capabilities"] == ["rx", "tx"]
|
|
assert p["tx_enabled"] is True
|
|
|
|
|
|
def test_heartbeat_payload_sessions_field():
|
|
sessions = {"rx": {"app_id": "a", "state": "streaming"}}
|
|
p = hardware.heartbeat_payload(status="streaming", app_id="a", sessions=sessions)
|
|
assert p["sessions"] == sessions
|