Improve performance of bluetooth coordinators (#98997)

This commit is contained in:
J. Nick Koston
2023-08-25 03:31:43 -05:00
committed by GitHub
parent c2713f0aed
commit 3ebf96143a
2 changed files with 18 additions and 4 deletions

View File

@@ -406,7 +406,7 @@ async def test_exception_from_update_method(
"""Generate mock data."""
nonlocal run_count
run_count += 1
if run_count == 1:
if run_count == 2:
raise Exception("Test exception")
return GENERIC_PASSIVE_BLUETOOTH_DATA_UPDATE
@@ -436,6 +436,7 @@ async def test_exception_from_update_method(
processor.async_add_listener(MagicMock())
inject_bluetooth_service_info(hass, GENERIC_BLUETOOTH_SERVICE_INFO)
saved_callback(GENERIC_BLUETOOTH_SERVICE_INFO, BluetoothChange.ADVERTISEMENT)
assert processor.available is True
# We should go unavailable once we get an exception
@@ -473,7 +474,7 @@ async def test_bad_data_from_update_method(
"""Generate mock data."""
nonlocal run_count
run_count += 1
if run_count == 1:
if run_count == 2:
return "bad_data"
return GENERIC_PASSIVE_BLUETOOTH_DATA_UPDATE
@@ -503,6 +504,7 @@ async def test_bad_data_from_update_method(
processor.async_add_listener(MagicMock())
inject_bluetooth_service_info(hass, GENERIC_BLUETOOTH_SERVICE_INFO)
saved_callback(GENERIC_BLUETOOTH_SERVICE_INFO, BluetoothChange.ADVERTISEMENT)
assert processor.available is True
# We should go unavailable once we get bad data