mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Raise on bad update data instead of log in PassiveBluetoothDataUpdateCoordinator (#75536)
This commit is contained in:
parent
8523c66bb5
commit
f3c4bf571b
@ -261,12 +261,9 @@ class PassiveBluetoothDataUpdateCoordinator(Generic[_T]):
|
||||
|
||||
if not isinstance(new_data, PassiveBluetoothDataUpdate):
|
||||
self.last_update_success = False # type: ignore[unreachable]
|
||||
self.logger.error(
|
||||
"The update_method for %s returned %s instead of a PassiveBluetoothDataUpdate",
|
||||
self.name,
|
||||
new_data,
|
||||
raise ValueError(
|
||||
f"The update_method for {self.name} returned {new_data} instead of a PassiveBluetoothDataUpdate"
|
||||
)
|
||||
return
|
||||
|
||||
if not self.last_update_success:
|
||||
self.last_update_success = True
|
||||
|
@ -7,6 +7,7 @@ import time
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from home_assistant_bluetooth import BluetoothServiceInfo
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.bluetooth import BluetoothChange
|
||||
from homeassistant.components.bluetooth.passive_update_coordinator import (
|
||||
@ -337,7 +338,7 @@ async def test_exception_from_update_method(hass, caplog):
|
||||
cancel_coordinator()
|
||||
|
||||
|
||||
async def test_bad_data_from_update_method(hass, caplog):
|
||||
async def test_bad_data_from_update_method(hass):
|
||||
"""Test we handle bad data from the update method."""
|
||||
run_count = 0
|
||||
|
||||
@ -373,9 +374,9 @@ async def test_bad_data_from_update_method(hass, caplog):
|
||||
assert coordinator.available is True
|
||||
|
||||
# We should go unavailable once we get bad data
|
||||
saved_callback(GENERIC_BLUETOOTH_SERVICE_INFO, BluetoothChange.ADVERTISEMENT)
|
||||
assert "update_method" in caplog.text
|
||||
assert "bad_data" in caplog.text
|
||||
with pytest.raises(ValueError):
|
||||
saved_callback(GENERIC_BLUETOOTH_SERVICE_INFO, BluetoothChange.ADVERTISEMENT)
|
||||
|
||||
assert coordinator.available is False
|
||||
|
||||
# We should go available again once we get good data again
|
||||
|
Loading…
x
Reference in New Issue
Block a user