mirror of
https://github.com/home-assistant/core.git
synced 2026-09-28 02:18:10 -04:00
Add alarm and connectivity binary_sensors to myuplink (#111643)
* Add alarm and connectivity binary_sensors * Get is_on for correct system * Make coverage 100% in binary_sensor * Address review comments * Revert dict comprehension for now
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.const import STATE_OFF, STATE_ON
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from . import setup_integration
|
||||
@@ -9,17 +12,46 @@ from . import setup_integration
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
# Test one entity from each of binary_sensor classes.
|
||||
@pytest.mark.parametrize(
|
||||
("entity_id", "friendly_name", "test_attributes", "expected_state"),
|
||||
[
|
||||
(
|
||||
"binary_sensor.gotham_city_pump_heating_medium_gp1",
|
||||
"Gotham City Pump: Heating medium (GP1)",
|
||||
True,
|
||||
STATE_ON,
|
||||
),
|
||||
(
|
||||
"binary_sensor.gotham_city_connectivity",
|
||||
"Gotham City Connectivity",
|
||||
False,
|
||||
STATE_ON,
|
||||
),
|
||||
(
|
||||
"binary_sensor.gotham_city_alarm",
|
||||
"Gotham City Pump: Alarm",
|
||||
False,
|
||||
STATE_OFF,
|
||||
),
|
||||
],
|
||||
)
|
||||
async def test_sensor_states(
|
||||
hass: HomeAssistant,
|
||||
mock_myuplink_client: MagicMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
entity_id: str,
|
||||
friendly_name: str,
|
||||
test_attributes: bool,
|
||||
expected_state: str,
|
||||
) -> None:
|
||||
"""Test sensor state."""
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
state = hass.states.get("binary_sensor.gotham_city_pump_heating_medium_gp1")
|
||||
state = hass.states.get(entity_id)
|
||||
assert state is not None
|
||||
assert state.state == "on"
|
||||
assert state.attributes == {
|
||||
"friendly_name": "Gotham City Pump: Heating medium (GP1)",
|
||||
}
|
||||
assert state.state == expected_state
|
||||
if test_attributes:
|
||||
assert state.attributes == {
|
||||
"friendly_name": friendly_name,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user