Стабилизация подключения K1 после сна и ожидания Bluetooth
This commit is contained in:
@@ -79,7 +79,7 @@ def test_ap_activation_uses_retained_handle_without_rediscovery(
|
||||
device_id = "synthetic-corebluetooth-uuid"
|
||||
retained_handle = BLEDevice(device_id, "XGR-K1", details=object())
|
||||
rediscovery_calls: list[tuple[str, float]] = []
|
||||
client_calls: list[object] = []
|
||||
client_calls: list[tuple[object, float, bool]] = []
|
||||
|
||||
class SelectedHandleObserved(RuntimeError):
|
||||
pass
|
||||
@@ -89,8 +89,14 @@ def test_ap_activation_uses_retained_handle_without_rediscovery(
|
||||
raise AssertionError("a fresh explicit scan handle must be used directly")
|
||||
|
||||
class CapturingClient:
|
||||
def __init__(self, device: object, **_kwargs: object) -> None:
|
||||
client_calls.append(device)
|
||||
def __init__(
|
||||
self,
|
||||
device: object,
|
||||
*,
|
||||
timeout: float,
|
||||
pair: bool,
|
||||
) -> None:
|
||||
client_calls.append((device, timeout, pair))
|
||||
raise SelectedHandleObserved
|
||||
|
||||
monkeypatch.setattr(scanner_module, "monotonic", lambda: 100.0)
|
||||
@@ -117,6 +123,7 @@ def test_ap_activation_uses_retained_handle_without_rediscovery(
|
||||
await ap_module.activate_device_ap_once(
|
||||
device_id,
|
||||
timeout_seconds=1.0,
|
||||
connect_timeout_seconds=30.0,
|
||||
captured_device=captured,
|
||||
)
|
||||
assert (
|
||||
@@ -131,7 +138,7 @@ def test_ap_activation_uses_retained_handle_without_rediscovery(
|
||||
error = asyncio.run(scenario())
|
||||
|
||||
assert rediscovery_calls == []
|
||||
assert client_calls == [retained_handle]
|
||||
assert client_calls == [(retained_handle, 30.0, False)]
|
||||
assert error.operation_stage == "connect" # type: ignore[attr-defined]
|
||||
assert error.device_write_attempted is False # type: ignore[attr-defined]
|
||||
assert error.device_write_confirmed is False # type: ignore[attr-defined]
|
||||
|
||||
Reference in New Issue
Block a user