Fix dangerous-default-value warnings in greeneye_monitor tests (#119581)

This commit is contained in:
epenet 2024-06-13 16:47:53 +02:00 committed by GitHub
parent 9f322b20d1
commit e34c42c0a9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -19,13 +19,15 @@ def assert_sensor_state(
hass: HomeAssistant, hass: HomeAssistant,
entity_id: str, entity_id: str,
expected_state: str, expected_state: str,
attributes: dict[str, Any] = {}, attributes: dict[str, Any] | None = None,
) -> None: ) -> None:
"""Assert that the given entity has the expected state and at least the provided attributes.""" """Assert that the given entity has the expected state and at least the provided attributes."""
state = hass.states.get(entity_id) state = hass.states.get(entity_id)
assert state assert state
actual_state = state.state actual_state = state.state
assert actual_state == expected_state assert actual_state == expected_state
if not attributes:
return
for key, value in attributes.items(): for key, value in attributes.items():
assert key in state.attributes assert key in state.attributes
assert state.attributes[key] == value assert state.attributes[key] == value