1
0
mirror of https://github.com/home-assistant/core.git synced 2026-02-20 18:08:00 +00:00

Small cleanup for Vodafone Station tests (#160415)

This commit is contained in:
Simone Chemelli
2026-01-07 12:50:12 +01:00
committed by GitHub
parent a2fb8f5a72
commit db497b23fe
3 changed files with 12 additions and 5 deletions

View File

@@ -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"

View File

@@ -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,
)

View File

@@ -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