mirror of
https://github.com/home-assistant/core.git
synced 2026-09-12 11:38:47 +01:00
Make FRITZ!Box Tools tests more reliable (#161719)
This commit is contained in:
@@ -32,26 +32,6 @@ class FritzServiceMock(Service):
|
||||
self.serviceId = serviceId
|
||||
|
||||
|
||||
class FritzResponseMock:
|
||||
"""Response mocking."""
|
||||
|
||||
def json(self):
|
||||
"""Mock json method."""
|
||||
return {"CPUTEMP": "69,68,67"}
|
||||
|
||||
|
||||
class FritzHttpMock:
|
||||
"""FritzHttp mocking."""
|
||||
|
||||
def __init__(self) -> None:
|
||||
"""Init Mocking class."""
|
||||
self.router_url = "http://fritz.box"
|
||||
|
||||
def call_url(self, *args, **kwargs):
|
||||
"""Mock call_url method."""
|
||||
return FritzResponseMock()
|
||||
|
||||
|
||||
class FritzConnectionMock:
|
||||
"""FritzConnection mocking."""
|
||||
|
||||
@@ -64,7 +44,6 @@ class FritzConnectionMock:
|
||||
srv: FritzServiceMock(serviceId=srv, actions=actions)
|
||||
for srv, actions in services.items()
|
||||
}
|
||||
self.http_interface = FritzHttpMock()
|
||||
LOGGER.debug("-" * 80)
|
||||
LOGGER.debug("FritzConnectionMock - services: %s", self.services)
|
||||
|
||||
|
||||
@@ -13,9 +13,8 @@
|
||||
]),
|
||||
'connection_type': 'WANPPPConnection',
|
||||
'cpu_temperatures': list([
|
||||
69,
|
||||
68,
|
||||
67,
|
||||
42,
|
||||
38,
|
||||
]),
|
||||
'current_firmware': '7.29',
|
||||
'current_user_rights': dict({
|
||||
|
||||
@@ -49,6 +49,63 @@
|
||||
'state': '2024-09-01T10:11:33+00:00',
|
||||
})
|
||||
# ---
|
||||
# name: test_sensor_setup[sensor.mock_title_cpu_temperature-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'config_subentry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'sensor',
|
||||
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
|
||||
'entity_id': 'sensor.mock_title_cpu_temperature',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'object_id_base': 'CPU temperature',
|
||||
'options': dict({
|
||||
'sensor': dict({
|
||||
'suggested_display_precision': 1,
|
||||
}),
|
||||
}),
|
||||
'original_device_class': <SensorDeviceClass.TEMPERATURE: 'temperature'>,
|
||||
'original_icon': None,
|
||||
'original_name': 'CPU temperature',
|
||||
'platform': 'fritz',
|
||||
'previous_unique_id': None,
|
||||
'suggested_object_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'cpu_temperature',
|
||||
'unique_id': '1C:ED:6F:12:34:11-cpu_temperature',
|
||||
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
|
||||
})
|
||||
# ---
|
||||
# name: test_sensor_setup[sensor.mock_title_cpu_temperature-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'device_class': 'temperature',
|
||||
'friendly_name': 'Mock Title CPU temperature',
|
||||
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
|
||||
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'sensor.mock_title_cpu_temperature',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': '42',
|
||||
})
|
||||
# ---
|
||||
# name: test_sensor_setup[sensor.mock_title_download_throughput-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
@@ -841,60 +898,3 @@
|
||||
'state': '3.4',
|
||||
})
|
||||
# ---
|
||||
# name: test_sensor_setup[sensor.mock_title_cpu_temperature-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'config_subentry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'sensor',
|
||||
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
|
||||
'entity_id': 'sensor.mock_title_cpu_temperature',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'object_id_base': 'CPU temperature',
|
||||
'options': dict({
|
||||
'sensor': dict({
|
||||
'suggested_display_precision': 1,
|
||||
}),
|
||||
}),
|
||||
'original_device_class': <SensorDeviceClass.TEMPERATURE: 'temperature'>,
|
||||
'original_icon': None,
|
||||
'original_name': 'CPU temperature',
|
||||
'platform': 'fritz',
|
||||
'previous_unique_id': None,
|
||||
'suggested_object_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'cpu_temperature',
|
||||
'unique_id': '1C:ED:6F:12:34:11-cpu_temperature',
|
||||
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
|
||||
})
|
||||
# ---
|
||||
# name: test_sensor_setup[sensor.mock_title_cpu_temperature-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'device_class': 'temperature',
|
||||
'friendly_name': 'Mock Title CPU temperature',
|
||||
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
|
||||
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'sensor.mock_title_cpu_temperature',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': '69',
|
||||
})
|
||||
# ---
|
||||
|
||||
@@ -727,7 +727,7 @@ async def test_ssdp_exception(hass: HomeAssistant) -> None:
|
||||
assert result["step_id"] == "confirm"
|
||||
|
||||
|
||||
async def test_options_flow(hass: HomeAssistant) -> None:
|
||||
async def test_options_flow(hass: HomeAssistant, fc_class_mock) -> None:
|
||||
"""Test options flow."""
|
||||
|
||||
mock_config = MockConfigEntry(domain=DOMAIN, data=MOCK_USER_DATA)
|
||||
|
||||
@@ -20,6 +20,7 @@ async def test_entry_diagnostics(
|
||||
hass_client: ClientSessionGenerator,
|
||||
fc_class_mock,
|
||||
fh_class_mock,
|
||||
fs_class_mock,
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test config entry diagnostics."""
|
||||
|
||||
@@ -28,6 +28,7 @@ async def test_sensor_setup(
|
||||
entity_registry: er.EntityRegistry,
|
||||
fc_class_mock,
|
||||
fh_class_mock,
|
||||
fs_class_mock,
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test setup of Fritz!Tools sensors."""
|
||||
|
||||
Reference in New Issue
Block a user