Preserve RRD preview frames and clarify onboard K1 status
This commit is contained in:
@@ -134,8 +134,10 @@ def test_parse_wifi_status_rejects_short_frame() -> None:
|
||||
parse_wifi_status(bytes(50))
|
||||
|
||||
|
||||
@pytest.mark.parametrize("current_handle", [True, False])
|
||||
def test_read_wifi_status_once_reads_only_and_returns_current_dhcp_address(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
current_handle: bool,
|
||||
) -> None:
|
||||
value = bytearray(54)
|
||||
value[0] = 11
|
||||
@@ -167,8 +169,11 @@ def test_read_wifi_status_once_reads_only_and_returns_current_dhcp_address(
|
||||
return status_characteristic
|
||||
return None
|
||||
|
||||
connected = []
|
||||
|
||||
class FakeClient:
|
||||
def __init__(self, _device: object, **_kwargs: object) -> None:
|
||||
connected.append(_device)
|
||||
self.services = FakeServices()
|
||||
self.name = "XGR-K1"
|
||||
self.mtu_size = 256
|
||||
@@ -197,6 +202,19 @@ def test_read_wifi_status_once_reads_only_and_returns_current_dhcp_address(
|
||||
),
|
||||
)
|
||||
monkeypatch.setattr(wifi_module, "BleakClient", FakeClient)
|
||||
fresh_handle, capture, scans = object(), object(), []
|
||||
|
||||
async def is_current(_device):
|
||||
return current_handle
|
||||
|
||||
async def refresh_exact(address, **_kwargs):
|
||||
scans.append(address)
|
||||
return capture
|
||||
|
||||
monkeypatch.setattr(wifi_module, "status_read_device_is_current", is_current)
|
||||
monkeypatch.setattr(wifi_module, "discover_known_device_capture_for_status_read", refresh_exact)
|
||||
monkeypatch.setattr(wifi_module, "captured_device_handle", lambda value: fresh_handle)
|
||||
monkeypatch.setattr(wifi_module, "mark_captured_device_gatt_validated", lambda *_a, **_k: True)
|
||||
|
||||
result = asyncio.run(read_wifi_status_once("synthetic-corebluetooth-uuid"))
|
||||
|
||||
@@ -207,6 +225,8 @@ def test_read_wifi_status_once_reads_only_and_returns_current_dhcp_address(
|
||||
assert result["max_write_without_response_size"] == 244
|
||||
assert result["mtu_size"] == 256
|
||||
assert result["status"]["ipv4"] == "10.255.254.77"
|
||||
assert connected == [retained_handle if current_handle else fresh_handle]
|
||||
assert scans == ([] if current_handle else ["synthetic-corebluetooth-uuid"])
|
||||
|
||||
|
||||
def test_read_wifi_status_recovery_keeps_fresh_retained_handle(
|
||||
|
||||
Reference in New Issue
Block a user