From db497b23feeb41fa919b38393fd65bc474e2decc Mon Sep 17 00:00:00 2001 From: Simone Chemelli Date: Wed, 7 Jan 2026 12:50:12 +0100 Subject: [PATCH] Small cleanup for Vodafone Station tests (#160415) --- tests/components/vodafone_station/const.py | 1 + tests/components/vodafone_station/test_button.py | 5 +++-- tests/components/vodafone_station/test_sensor.py | 11 ++++++++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/tests/components/vodafone_station/const.py b/tests/components/vodafone_station/const.py index 071ef7b5094..435bad01874 100644 --- a/tests/components/vodafone_station/const.py +++ b/tests/components/vodafone_station/const.py @@ -12,3 +12,4 @@ TEST_PASSWORD = "fake_password" TEST_TYPE = DeviceType.SERCOMM TEST_URL = f"https://{TEST_HOST}" TEST_USERNAME = "fake_username" +TEST_SERIAL_NUMBER = "m123456789" diff --git a/tests/components/vodafone_station/test_button.py b/tests/components/vodafone_station/test_button.py index 84df839cae0..a7d1759c949 100644 --- a/tests/components/vodafone_station/test_button.py +++ b/tests/components/vodafone_station/test_button.py @@ -19,6 +19,7 @@ from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers import entity_registry as er from . import setup_integration +from .const import TEST_SERIAL_NUMBER from tests.common import MockConfigEntry, snapshot_platform @@ -51,7 +52,7 @@ async def test_pressing_button( await hass.services.async_call( BUTTON_DOMAIN, SERVICE_PRESS, - {ATTR_ENTITY_ID: "button.vodafone_station_m123456789_restart"}, + {ATTR_ENTITY_ID: f"button.vodafone_station_{TEST_SERIAL_NUMBER}_restart"}, blocking=True, ) mock_vodafone_station_router.restart_router.assert_called_once() @@ -84,7 +85,7 @@ async def test_button_fails( await hass.services.async_call( BUTTON_DOMAIN, SERVICE_PRESS, - {ATTR_ENTITY_ID: "button.vodafone_station_m123456789_restart"}, + {ATTR_ENTITY_ID: f"button.vodafone_station_{TEST_SERIAL_NUMBER}_restart"}, blocking=True, ) diff --git a/tests/components/vodafone_station/test_sensor.py b/tests/components/vodafone_station/test_sensor.py index b005f8eba44..65adf107756 100644 --- a/tests/components/vodafone_station/test_sensor.py +++ b/tests/components/vodafone_station/test_sensor.py @@ -13,6 +13,7 @@ from homeassistant.core import HomeAssistant from homeassistant.helpers import entity_registry as er from . import setup_integration +from .const import TEST_SERIAL_NUMBER from tests.common import MockConfigEntry, async_fire_time_changed, snapshot_platform @@ -52,7 +53,9 @@ async def test_active_connection_type( """Test device connection type.""" await setup_integration(hass, mock_config_entry) - active_connection_entity = "sensor.vodafone_station_m123456789_active_connection" + active_connection_entity = ( + f"sensor.vodafone_station_{TEST_SERIAL_NUMBER}_active_connection" + ) assert (state := hass.states.get(active_connection_entity)) assert state.state == STATE_UNKNOWN @@ -80,7 +83,7 @@ async def test_uptime( await setup_integration(hass, mock_config_entry) uptime = "2024-11-19T20:19:00+00:00" - uptime_entity = "sensor.vodafone_station_m123456789_uptime" + uptime_entity = f"sensor.vodafone_station_{TEST_SERIAL_NUMBER}_uptime" assert (state := hass.states.get(uptime_entity)) assert state.state == uptime @@ -119,5 +122,7 @@ async def test_coordinator_client_connector_error( async_fire_time_changed(hass) await hass.async_block_till_done(wait_background_tasks=True) - assert (state := hass.states.get("sensor.vodafone_station_m123456789_uptime")) + assert ( + state := hass.states.get(f"sensor.vodafone_station_{TEST_SERIAL_NUMBER}_uptime") + ) assert state.state == STATE_UNAVAILABLE