From 923c13907cde2a79e97cea08a32ee1d4b038c96c Mon Sep 17 00:00:00 2001 From: Quentame Date: Mon, 20 Nov 2023 15:01:18 +0100 Subject: [PATCH] Fix Freebox Home alarm & improve platform tests (#103475) * Fix Freebox Home alarm * Add trigger feature test & fix * FreeboxCallSensor: Add test for missing coverage of new call * Use generator Co-authored-by: Martin Hjelmare * Add test for arm_home feature (questions about the check) * Stay focus on alam tests * can_arm_home ==> if _command_arm_home * Use one liner for supported_features * Add idle state * Fix rebase --------- Co-authored-by: Martin Hjelmare --- .../components/freebox/alarm_control_panel.py | 71 ++---- homeassistant/components/freebox/home_base.py | 9 +- tests/components/freebox/conftest.py | 14 +- tests/components/freebox/const.py | 14 +- ..._values.json => home_alarm_get_value.json} | 2 +- ...et_values.json => home_pir_get_value.json} | 0 .../freebox/fixtures/home_set_value.json | 3 + .../freebox/test_alarm_control_panel.py | 210 +++++++++++------- .../components/freebox/test_binary_sensor.py | 6 +- tests/components/freebox/test_button.py | 2 +- tests/components/freebox/test_init.py | 2 +- tests/components/freebox/test_router.py | 4 +- 12 files changed, 186 insertions(+), 151 deletions(-) rename tests/components/freebox/fixtures/{home_alarm_get_values.json => home_alarm_get_value.json} (64%) rename tests/components/freebox/fixtures/{home_pir_get_values.json => home_pir_get_value.json} (100%) create mode 100644 tests/components/freebox/fixtures/home_set_value.json diff --git a/homeassistant/components/freebox/alarm_control_panel.py b/homeassistant/components/freebox/alarm_control_panel.py index 52b7109045c..be3d88cf5b4 100644 --- a/homeassistant/components/freebox/alarm_control_panel.py +++ b/homeassistant/components/freebox/alarm_control_panel.py @@ -1,5 +1,4 @@ """Support for Freebox alarms.""" -import logging from typing import Any from homeassistant.components.alarm_control_panel import ( @@ -9,7 +8,7 @@ from homeassistant.components.alarm_control_panel import ( from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( STATE_ALARM_ARMED_AWAY, - STATE_ALARM_ARMED_NIGHT, + STATE_ALARM_ARMED_HOME, STATE_ALARM_ARMING, STATE_ALARM_DISARMED, STATE_ALARM_TRIGGERED, @@ -25,16 +24,14 @@ FREEBOX_TO_STATUS = { "alarm1_arming": STATE_ALARM_ARMING, "alarm2_arming": STATE_ALARM_ARMING, "alarm1_armed": STATE_ALARM_ARMED_AWAY, - "alarm2_armed": STATE_ALARM_ARMED_NIGHT, + "alarm2_armed": STATE_ALARM_ARMED_HOME, "alarm1_alert_timer": STATE_ALARM_TRIGGERED, "alarm2_alert_timer": STATE_ALARM_TRIGGERED, "alert": STATE_ALARM_TRIGGERED, + "idle": STATE_ALARM_DISARMED, } -_LOGGER = logging.getLogger(__name__) - - async def async_setup_entry( hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback ) -> None: @@ -76,63 +73,33 @@ class FreeboxAlarm(FreeboxHomeEntity, AlarmControlPanelEntity): self._command_state = self.get_command_id( node["type"]["endpoints"], "signal", "state" ) - self._set_features(self._router.home_devices[self._id]) + + self._attr_supported_features = ( + AlarmControlPanelEntityFeature.ARM_AWAY + | (AlarmControlPanelEntityFeature.ARM_HOME if self._command_arm_home else 0) + | AlarmControlPanelEntityFeature.TRIGGER + ) async def async_alarm_disarm(self, code: str | None = None) -> None: """Send disarm command.""" - if await self.set_home_endpoint_value(self._command_disarm): - self._set_state(STATE_ALARM_DISARMED) + await self.set_home_endpoint_value(self._command_disarm) async def async_alarm_arm_away(self, code: str | None = None) -> None: """Send arm away command.""" - if await self.set_home_endpoint_value(self._command_arm_away): - self._set_state(STATE_ALARM_ARMING) + await self.set_home_endpoint_value(self._command_arm_away) async def async_alarm_arm_home(self, code: str | None = None) -> None: """Send arm home command.""" - if await self.set_home_endpoint_value(self._command_arm_home): - self._set_state(STATE_ALARM_ARMING) + await self.set_home_endpoint_value(self._command_arm_home) async def async_alarm_trigger(self, code: str | None = None) -> None: """Send alarm trigger command.""" - if await self.set_home_endpoint_value(self._command_trigger): - self._set_state(STATE_ALARM_TRIGGERED) + await self.set_home_endpoint_value(self._command_trigger) - async def async_update_signal(self): - """Update signal.""" - state = await self.get_home_endpoint_value(self._command_state) - if state: - self._set_state(state) - - def _set_features(self, node: dict[str, Any]) -> None: - """Add alarm features.""" - # Search if the arm home feature is present => has an "alarm2" endpoint - can_arm_home = False - for nodeid, local_node in self._router.home_devices.items(): - if nodeid == local_node["id"]: - alarm2 = next( - filter( - lambda x: (x["name"] == "alarm2" and x["ep_type"] == "signal"), - local_node["show_endpoints"], - ), - None, - ) - if alarm2: - can_arm_home = alarm2["value"] - break - - if can_arm_home: - self._attr_supported_features = ( - AlarmControlPanelEntityFeature.ARM_AWAY - | AlarmControlPanelEntityFeature.ARM_HOME - ) - - else: - self._attr_supported_features = AlarmControlPanelEntityFeature.ARM_AWAY - - def _set_state(self, state: str) -> None: + async def async_update(self) -> None: """Update state.""" - self._attr_state = FREEBOX_TO_STATUS.get(state) - if not self._attr_state: - self._attr_state = STATE_ALARM_DISARMED - self.async_write_ha_state() + state: str | None = await self.get_home_endpoint_value(self._command_state) + if state: + self._attr_state = FREEBOX_TO_STATUS.get(state) + else: + self._attr_state = None diff --git a/homeassistant/components/freebox/home_base.py b/homeassistant/components/freebox/home_base.py index 2cc1a5fcfe3..022528e5ea7 100644 --- a/homeassistant/components/freebox/home_base.py +++ b/homeassistant/components/freebox/home_base.py @@ -131,13 +131,14 @@ class FreeboxHomeEntity(Entity): def get_value(self, ep_type: str, name: str): """Get the value.""" node = next( - filter( - lambda x: (x["name"] == name and x["ep_type"] == ep_type), - self._node["show_endpoints"], + ( + endpoint + for endpoint in self._node["show_endpoints"] + if endpoint["name"] == name and endpoint["ep_type"] == ep_type ), None, ) - if not node: + if node is None: _LOGGER.warning( "The Freebox Home device has no node value for: %s/%s", ep_type, name ) diff --git a/tests/components/freebox/conftest.py b/tests/components/freebox/conftest.py index 39ed596e6db..3ba175cbc75 100644 --- a/tests/components/freebox/conftest.py +++ b/tests/components/freebox/conftest.py @@ -12,13 +12,14 @@ from .const import ( DATA_CALL_GET_CALLS_LOG, DATA_CONNECTION_GET_STATUS, DATA_HOME_GET_NODES, - DATA_HOME_PIR_GET_VALUES, + DATA_HOME_PIR_GET_VALUE, + DATA_HOME_SET_VALUE, DATA_LAN_GET_HOSTS_LIST, DATA_LAN_GET_HOSTS_LIST_MODE_BRIDGE, DATA_STORAGE_GET_DISKS, DATA_STORAGE_GET_RAIDS, DATA_SYSTEM_GET_CONFIG, - WIFI_GET_GLOBAL_CONFIG, + DATA_WIFI_GET_GLOBAL_CONFIG, ) from tests.common import MockConfigEntry @@ -84,11 +85,16 @@ def mock_router(mock_device_registry_devices): return_value=DATA_CONNECTION_GET_STATUS ) # switch - instance.wifi.get_global_config = AsyncMock(return_value=WIFI_GET_GLOBAL_CONFIG) + instance.wifi.get_global_config = AsyncMock( + return_value=DATA_WIFI_GET_GLOBAL_CONFIG + ) # home devices instance.home.get_home_nodes = AsyncMock(return_value=DATA_HOME_GET_NODES) instance.home.get_home_endpoint_value = AsyncMock( - return_value=DATA_HOME_PIR_GET_VALUES + return_value=DATA_HOME_PIR_GET_VALUE + ) + instance.home.set_home_endpoint_value = AsyncMock( + return_value=DATA_HOME_SET_VALUE ) instance.close = AsyncMock() yield service_mock diff --git a/tests/components/freebox/const.py b/tests/components/freebox/const.py index 84667bf9d70..ae07b39c5e8 100644 --- a/tests/components/freebox/const.py +++ b/tests/components/freebox/const.py @@ -21,7 +21,9 @@ DATA_STORAGE_GET_DISKS = load_json_array_fixture("freebox/storage_get_disks.json DATA_STORAGE_GET_RAIDS = load_json_array_fixture("freebox/storage_get_raids.json") # switch -WIFI_GET_GLOBAL_CONFIG = load_json_object_fixture("freebox/wifi_get_global_config.json") +DATA_WIFI_GET_GLOBAL_CONFIG = load_json_object_fixture( + "freebox/wifi_get_global_config.json" +) # device_tracker DATA_LAN_GET_HOSTS_LIST = load_json_array_fixture("freebox/lan_get_hosts_list.json") @@ -35,10 +37,14 @@ DATA_HOME_GET_NODES = load_json_array_fixture("freebox/home_get_nodes.json") # Home # PIR node id 26, endpoint id 6 -DATA_HOME_PIR_GET_VALUES = load_json_object_fixture("freebox/home_pir_get_values.json") +DATA_HOME_PIR_GET_VALUE = load_json_object_fixture("freebox/home_pir_get_value.json") # Home # ALARM node id 7, endpoint id 11 -DATA_HOME_ALARM_GET_VALUES = load_json_object_fixture( - "freebox/home_alarm_get_values.json" +DATA_HOME_ALARM_GET_VALUE = load_json_object_fixture( + "freebox/home_alarm_get_value.json" ) + +# Home +# Set a node value with success +DATA_HOME_SET_VALUE = load_json_object_fixture("freebox/home_set_value.json") diff --git a/tests/components/freebox/fixtures/home_alarm_get_values.json b/tests/components/freebox/fixtures/home_alarm_get_value.json similarity index 64% rename from tests/components/freebox/fixtures/home_alarm_get_values.json rename to tests/components/freebox/fixtures/home_alarm_get_value.json index 1e43a428296..6e4ad4d0538 100644 --- a/tests/components/freebox/fixtures/home_alarm_get_values.json +++ b/tests/components/freebox/fixtures/home_alarm_get_value.json @@ -1,5 +1,5 @@ { "refresh": 2000, - "value": "alarm2_armed", + "value": "alarm1_armed", "value_type": "string" } diff --git a/tests/components/freebox/fixtures/home_pir_get_values.json b/tests/components/freebox/fixtures/home_pir_get_value.json similarity index 100% rename from tests/components/freebox/fixtures/home_pir_get_values.json rename to tests/components/freebox/fixtures/home_pir_get_value.json diff --git a/tests/components/freebox/fixtures/home_set_value.json b/tests/components/freebox/fixtures/home_set_value.json new file mode 100644 index 00000000000..5550c6db40a --- /dev/null +++ b/tests/components/freebox/fixtures/home_set_value.json @@ -0,0 +1,3 @@ +{ + "success": true +} diff --git a/tests/components/freebox/test_alarm_control_panel.py b/tests/components/freebox/test_alarm_control_panel.py index d24c747f2a3..44286f18b87 100644 --- a/tests/components/freebox/test_alarm_control_panel.py +++ b/tests/components/freebox/test_alarm_control_panel.py @@ -1,57 +1,68 @@ -"""Tests for the Freebox sensors.""" +"""Tests for the Freebox alarms.""" from copy import deepcopy from unittest.mock import Mock from freezegun.api import FrozenDateTimeFactory -import pytest from homeassistant.components.alarm_control_panel import ( - DOMAIN as ALARM_CONTROL_PANEL, + DOMAIN as ALARM_CONTROL_PANEL_DOMAIN, AlarmControlPanelEntityFeature, ) from homeassistant.components.freebox import SCAN_INTERVAL from homeassistant.const import ( + ATTR_ENTITY_ID, SERVICE_ALARM_ARM_AWAY, - SERVICE_ALARM_ARM_CUSTOM_BYPASS, SERVICE_ALARM_ARM_HOME, - SERVICE_ALARM_ARM_NIGHT, - SERVICE_ALARM_ARM_VACATION, SERVICE_ALARM_DISARM, SERVICE_ALARM_TRIGGER, STATE_ALARM_ARMED_AWAY, - STATE_ALARM_ARMED_CUSTOM_BYPASS, STATE_ALARM_ARMED_HOME, - STATE_ALARM_ARMED_NIGHT, - STATE_ALARM_ARMED_VACATION, + STATE_ALARM_ARMING, STATE_ALARM_DISARMED, STATE_ALARM_TRIGGERED, + STATE_UNKNOWN, ) -from homeassistant.core import HomeAssistant, State -from homeassistant.helpers.state import async_reproduce_state +from homeassistant.core import HomeAssistant from .common import setup_platform -from .const import DATA_HOME_ALARM_GET_VALUES +from .const import DATA_HOME_ALARM_GET_VALUE, DATA_HOME_GET_NODES -from tests.common import async_fire_time_changed, async_mock_service +from tests.common import async_fire_time_changed -async def test_panel( +async def test_alarm_changed_from_external( hass: HomeAssistant, freezer: FrozenDateTimeFactory, router: Mock ) -> None: - """Test home binary sensors.""" - await setup_platform(hass, ALARM_CONTROL_PANEL) + """Test Freebox Home alarm which state depends on external changes.""" + data_get_home_nodes = deepcopy(DATA_HOME_GET_NODES) + data_get_home_endpoint_value = deepcopy(DATA_HOME_ALARM_GET_VALUE) + + # Add remove arm_home feature + ALARM_NODE_ID = 7 + ALARM_HOME_ENDPOINT_ID = 2 + del data_get_home_nodes[ALARM_NODE_ID]["type"]["endpoints"][ALARM_HOME_ENDPOINT_ID] + router().home.get_home_nodes.return_value = data_get_home_nodes + + data_get_home_endpoint_value["value"] = "alarm1_arming" + router().home.get_home_endpoint_value.return_value = data_get_home_endpoint_value + + await setup_platform(hass, ALARM_CONTROL_PANEL_DOMAIN) + + # Attributes + assert hass.states.get("alarm_control_panel.systeme_d_alarme").attributes[ + "supported_features" + ] == ( + AlarmControlPanelEntityFeature.ARM_AWAY | AlarmControlPanelEntityFeature.TRIGGER + ) # Initial state - assert hass.states.get("alarm_control_panel.systeme_d_alarme").state == "unknown" assert ( - hass.states.get("alarm_control_panel.systeme_d_alarme").attributes[ - "supported_features" - ] - == AlarmControlPanelEntityFeature.ARM_AWAY + hass.states.get("alarm_control_panel.systeme_d_alarme").state + == STATE_ALARM_ARMING ) # Now simulate a changed status - data_get_home_endpoint_value = deepcopy(DATA_HOME_ALARM_GET_VALUES) + data_get_home_endpoint_value["value"] = "alarm1_armed" router().home.get_home_endpoint_value.return_value = data_get_home_endpoint_value # Simulate an update @@ -60,64 +71,105 @@ async def test_panel( await hass.async_block_till_done() assert ( - hass.states.get("alarm_control_panel.systeme_d_alarme").state == "armed_night" - ) - # Fake that the entity is triggered. - hass.states.async_set("alarm_control_panel.systeme_d_alarme", STATE_ALARM_DISARMED) - assert hass.states.get("alarm_control_panel.systeme_d_alarme").state == "disarmed" - - -async def test_reproducing_states( - hass: HomeAssistant, caplog: pytest.LogCaptureFixture -) -> None: - """Test reproducing Alarm control panel states.""" - hass.states.async_set( - "alarm_control_panel.entity_armed_away", STATE_ALARM_ARMED_AWAY, {} - ) - hass.states.async_set( - "alarm_control_panel.entity_armed_custom_bypass", - STATE_ALARM_ARMED_CUSTOM_BYPASS, - {}, - ) - hass.states.async_set( - "alarm_control_panel.entity_armed_home", STATE_ALARM_ARMED_HOME, {} - ) - hass.states.async_set( - "alarm_control_panel.entity_armed_night", STATE_ALARM_ARMED_NIGHT, {} - ) - hass.states.async_set( - "alarm_control_panel.entity_armed_vacation", STATE_ALARM_ARMED_VACATION, {} - ) - hass.states.async_set( - "alarm_control_panel.entity_disarmed", STATE_ALARM_DISARMED, {} - ) - hass.states.async_set( - "alarm_control_panel.entity_triggered", STATE_ALARM_TRIGGERED, {} + hass.states.get("alarm_control_panel.systeme_d_alarme").state + == STATE_ALARM_ARMED_AWAY ) - async_mock_service(hass, "alarm_control_panel", SERVICE_ALARM_ARM_AWAY) - async_mock_service(hass, "alarm_control_panel", SERVICE_ALARM_ARM_CUSTOM_BYPASS) - async_mock_service(hass, "alarm_control_panel", SERVICE_ALARM_ARM_HOME) - async_mock_service(hass, "alarm_control_panel", SERVICE_ALARM_ARM_NIGHT) - async_mock_service(hass, "alarm_control_panel", SERVICE_ALARM_ARM_VACATION) - async_mock_service(hass, "alarm_control_panel", SERVICE_ALARM_DISARM) - async_mock_service(hass, "alarm_control_panel", SERVICE_ALARM_TRIGGER) - # These calls should do nothing as entities already in desired state - await async_reproduce_state( - hass, - [ - State("alarm_control_panel.entity_armed_away", STATE_ALARM_ARMED_AWAY), - State( - "alarm_control_panel.entity_armed_custom_bypass", - STATE_ALARM_ARMED_CUSTOM_BYPASS, - ), - State("alarm_control_panel.entity_armed_home", STATE_ALARM_ARMED_HOME), - State("alarm_control_panel.entity_armed_night", STATE_ALARM_ARMED_NIGHT), - State( - "alarm_control_panel.entity_armed_vacation", STATE_ALARM_ARMED_VACATION - ), - State("alarm_control_panel.entity_disarmed", STATE_ALARM_DISARMED), - State("alarm_control_panel.entity_triggered", STATE_ALARM_TRIGGERED), - ], +async def test_alarm_changed_from_hass(hass: HomeAssistant, router: Mock) -> None: + """Test Freebox Home alarm which state depends on HA.""" + data_get_home_endpoint_value = deepcopy(DATA_HOME_ALARM_GET_VALUE) + + data_get_home_endpoint_value["value"] = "alarm1_armed" + router().home.get_home_endpoint_value.return_value = data_get_home_endpoint_value + + await setup_platform(hass, ALARM_CONTROL_PANEL_DOMAIN) + + # Attributes + assert hass.states.get("alarm_control_panel.systeme_d_alarme").attributes[ + "supported_features" + ] == ( + AlarmControlPanelEntityFeature.ARM_AWAY + | AlarmControlPanelEntityFeature.ARM_HOME + | AlarmControlPanelEntityFeature.TRIGGER + ) + + # Initial state: arm_away + assert ( + hass.states.get("alarm_control_panel.systeme_d_alarme").state + == STATE_ALARM_ARMED_AWAY + ) + + # Now call for a change -> disarmed + data_get_home_endpoint_value["value"] = "idle" + router().home.get_home_endpoint_value.return_value = data_get_home_endpoint_value + await hass.services.async_call( + ALARM_CONTROL_PANEL_DOMAIN, + SERVICE_ALARM_DISARM, + {ATTR_ENTITY_ID: ["alarm_control_panel.systeme_d_alarme"]}, + blocking=True, + ) + + assert ( + hass.states.get("alarm_control_panel.systeme_d_alarme").state + == STATE_ALARM_DISARMED + ) + + # Now call for a change -> arm_away + data_get_home_endpoint_value["value"] = "alarm1_arming" + router().home.get_home_endpoint_value.return_value = data_get_home_endpoint_value + await hass.services.async_call( + ALARM_CONTROL_PANEL_DOMAIN, + SERVICE_ALARM_ARM_AWAY, + {ATTR_ENTITY_ID: ["alarm_control_panel.systeme_d_alarme"]}, + blocking=True, + ) + + assert ( + hass.states.get("alarm_control_panel.systeme_d_alarme").state + == STATE_ALARM_ARMING + ) + + # Now call for a change -> arm_home + data_get_home_endpoint_value["value"] = "alarm2_armed" + # in reality: alarm2_arming then alarm2_armed + router().home.get_home_endpoint_value.return_value = data_get_home_endpoint_value + await hass.services.async_call( + ALARM_CONTROL_PANEL_DOMAIN, + SERVICE_ALARM_ARM_HOME, + {ATTR_ENTITY_ID: ["alarm_control_panel.systeme_d_alarme"]}, + blocking=True, + ) + + assert ( + hass.states.get("alarm_control_panel.systeme_d_alarme").state + == STATE_ALARM_ARMED_HOME + ) + + # Now call for a change -> trigger + data_get_home_endpoint_value["value"] = "alarm1_alert_timer" + router().home.get_home_endpoint_value.return_value = data_get_home_endpoint_value + await hass.services.async_call( + ALARM_CONTROL_PANEL_DOMAIN, + SERVICE_ALARM_TRIGGER, + {ATTR_ENTITY_ID: ["alarm_control_panel.systeme_d_alarme"]}, + blocking=True, + ) + + assert ( + hass.states.get("alarm_control_panel.systeme_d_alarme").state + == STATE_ALARM_TRIGGERED + ) + + +async def test_alarm_undefined_fetch_status(hass: HomeAssistant, router: Mock) -> None: + """Test Freebox Home alarm which state is undefined or null.""" + data_get_home_endpoint_value = deepcopy(DATA_HOME_ALARM_GET_VALUE) + data_get_home_endpoint_value["value"] = None + router().home.get_home_endpoint_value.return_value = data_get_home_endpoint_value + + await setup_platform(hass, ALARM_CONTROL_PANEL_DOMAIN) + + assert ( + hass.states.get("alarm_control_panel.systeme_d_alarme").state == STATE_UNKNOWN ) diff --git a/tests/components/freebox/test_binary_sensor.py b/tests/components/freebox/test_binary_sensor.py index 2fd308ea667..ee07af786be 100644 --- a/tests/components/freebox/test_binary_sensor.py +++ b/tests/components/freebox/test_binary_sensor.py @@ -1,4 +1,4 @@ -"""Tests for the Freebox sensors.""" +"""Tests for the Freebox binary sensors.""" from copy import deepcopy from unittest.mock import Mock @@ -13,7 +13,7 @@ from homeassistant.const import ATTR_DEVICE_CLASS from homeassistant.core import HomeAssistant from .common import setup_platform -from .const import DATA_HOME_PIR_GET_VALUES, DATA_STORAGE_GET_RAIDS +from .const import DATA_HOME_PIR_GET_VALUE, DATA_STORAGE_GET_RAIDS from tests.common import async_fire_time_changed @@ -73,7 +73,7 @@ async def test_home( assert hass.states.get("binary_sensor.ouverture_porte_couvercle").state == "off" # Now simulate a changed status - data_home_get_values_changed = deepcopy(DATA_HOME_PIR_GET_VALUES) + data_home_get_values_changed = deepcopy(DATA_HOME_PIR_GET_VALUE) data_home_get_values_changed["value"] = True router().home.get_home_endpoint_value.return_value = data_home_get_values_changed diff --git a/tests/components/freebox/test_button.py b/tests/components/freebox/test_button.py index 5f72b5968f1..209ab1e9fc2 100644 --- a/tests/components/freebox/test_button.py +++ b/tests/components/freebox/test_button.py @@ -1,4 +1,4 @@ -"""Tests for the Freebox config flow.""" +"""Tests for the Freebox buttons.""" from unittest.mock import ANY, AsyncMock, Mock, patch from pytest_unordered import unordered diff --git a/tests/components/freebox/test_init.py b/tests/components/freebox/test_init.py index 85acfdccc4d..9064727fb7f 100644 --- a/tests/components/freebox/test_init.py +++ b/tests/components/freebox/test_init.py @@ -1,4 +1,4 @@ -"""Tests for the Freebox config flow.""" +"""Tests for the Freebox init.""" from unittest.mock import ANY, Mock, patch from pytest_unordered import unordered diff --git a/tests/components/freebox/test_router.py b/tests/components/freebox/test_router.py index 595aab24fc9..572c168e665 100644 --- a/tests/components/freebox/test_router.py +++ b/tests/components/freebox/test_router.py @@ -3,7 +3,7 @@ import json from homeassistant.components.freebox.router import is_json -from .const import DATA_LAN_GET_HOSTS_LIST_MODE_BRIDGE, WIFI_GET_GLOBAL_CONFIG +from .const import DATA_LAN_GET_HOSTS_LIST_MODE_BRIDGE, DATA_WIFI_GET_GLOBAL_CONFIG async def test_is_json() -> None: @@ -12,7 +12,7 @@ async def test_is_json() -> None: # Valid JSON values assert is_json("{}") assert is_json('{ "simple":"json" }') - assert is_json(json.dumps(WIFI_GET_GLOBAL_CONFIG)) + assert is_json(json.dumps(DATA_WIFI_GET_GLOBAL_CONFIG)) assert is_json(json.dumps(DATA_LAN_GET_HOSTS_LIST_MODE_BRIDGE)) # Not valid JSON values