coverage
This commit is contained in:
parent
4b4510b644
commit
2e2b6747dd
|
@ -756,7 +756,11 @@ class APIClient:
|
|||
async def bluetooth_gatt_get_services(
|
||||
self, address: int
|
||||
) -> ESPHomeBluetoothGATTServices:
|
||||
append_types = (BluetoothGATTGetServicesResponse, BluetoothGATTErrorResponse)
|
||||
append_types = (
|
||||
BluetoothDeviceConnectionResponse,
|
||||
BluetoothGATTGetServicesResponse,
|
||||
BluetoothGATTErrorResponse,
|
||||
)
|
||||
stop_types = (
|
||||
BluetoothDeviceConnectionResponse,
|
||||
BluetoothGATTGetServicesDoneResponse,
|
||||
|
|
|
@ -1266,6 +1266,29 @@ async def test_bluetooth_gatt_write_descriptor_without_response(
|
|||
await client.bluetooth_gatt_write_descriptor(1234, 1234, b"1234", timeout=0)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_bluetooth_gatt_get_services_connection_drops(
|
||||
api_client: tuple[
|
||||
APIClient, APIConnection, asyncio.Transport, APIPlaintextFrameHelper
|
||||
],
|
||||
) -> None:
|
||||
"""Test connection drop during bluetooth_gatt_get_services."""
|
||||
client, connection, transport, protocol = api_client
|
||||
services_task = asyncio.create_task(client.bluetooth_gatt_get_services(1234))
|
||||
await asyncio.sleep(0)
|
||||
response: message.Message = BluetoothDeviceConnectionResponse(
|
||||
address=1234, connected=False, error=13
|
||||
)
|
||||
mock_data_received(protocol, generate_plaintext_packet(response))
|
||||
message = (
|
||||
"Peripheral 00:00:00:00:04:D2 changed connection status while waiting"
|
||||
" for BluetoothGATTGetServicesResponse, BluetoothGATTGetServicesDoneResponse, "
|
||||
"BluetoothGATTErrorResponse: Invalid attribute length"
|
||||
)
|
||||
with pytest.raises(BluetoothConnectionDroppedError, match=message):
|
||||
await services_task
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_bluetooth_gatt_get_services(
|
||||
api_client: tuple[
|
||||
|
|
Loading…
Reference in New Issue