mirror of
https://github.com/home-assistant/core.git
synced 2026-12-06 05:38:06 -04:00
Refactor sensor tests in libre_hardware_monitor integration (#189246)
This commit is contained in:
@@ -10,6 +10,12 @@ async def init_integration(
|
||||
) -> None:
|
||||
"""Mock integration setup."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
|
||||
async def setup_integration(
|
||||
hass: HomeAssistant, mock_config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Set up a config entry that has already been added."""
|
||||
await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
@@ -1465,7 +1465,7 @@
|
||||
'state': '97.0',
|
||||
})
|
||||
# ---
|
||||
# name: test_sensors_go_unavailable_on_error_and_recover[LibreHardwareMonitorConnectionError][valid_sensor_data]
|
||||
# name: test_sensors_go_unavailable_on_error_and_recover[LibreHardwareMonitorConnectionError-25][valid_sensor_data]
|
||||
list([
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
@@ -1859,7 +1859,7 @@
|
||||
}),
|
||||
])
|
||||
# ---
|
||||
# name: test_sensors_go_unavailable_on_error_and_recover[LibreHardwareMonitorNoDevicesError][valid_sensor_data]
|
||||
# name: test_sensors_go_unavailable_on_error_and_recover[LibreHardwareMonitorNoDevicesError-10][valid_sensor_data]
|
||||
list([
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
|
||||
@@ -9,6 +9,8 @@ from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from . import init_integration
|
||||
|
||||
|
||||
async def test_diagnostics(
|
||||
hass: HomeAssistant,
|
||||
@@ -18,9 +20,7 @@ async def test_diagnostics(
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test diagnostics."""
|
||||
mock_auth_config_entry.add_to_hass(hass)
|
||||
await hass.config_entries.async_setup(mock_auth_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
await init_integration(hass, mock_auth_config_entry)
|
||||
assert (
|
||||
await get_diagnostics_for_config_entry(
|
||||
hass, hass_client, mock_auth_config_entry
|
||||
|
||||
@@ -28,7 +28,7 @@ from homeassistant.const import (
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
|
||||
from . import init_integration
|
||||
from . import init_integration, setup_integration
|
||||
from .conftest import VALID_CONFIG
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ async def test_migration_to_unique_ids(
|
||||
== entity_object_id
|
||||
)
|
||||
|
||||
await init_integration(hass, legacy_config_entry_v1)
|
||||
await setup_integration(hass, legacy_config_entry_v1)
|
||||
|
||||
# Verify state after migration
|
||||
device_entries_after = dr.async_entries_for_config_entry(
|
||||
@@ -153,7 +153,7 @@ async def test_migration_to_sensor_device_classes(
|
||||
unit_of_measurement=LEGACY_THROUGHPUT_UNIT,
|
||||
)
|
||||
|
||||
await init_integration(hass, legacy_config_entry)
|
||||
await setup_integration(hass, legacy_config_entry)
|
||||
|
||||
entity_entry = entity_registry.async_get(f"sensor.{object_id}")
|
||||
assert entity_entry.unit_of_measurement == UnitOfDataRate.KIBIBYTES_PER_SECOND
|
||||
@@ -272,7 +272,7 @@ async def test_migration_to_binary_data_size_units(
|
||||
unit_of_measurement=legacy_unit,
|
||||
)
|
||||
|
||||
await init_integration(hass, legacy_config_entry)
|
||||
await setup_integration(hass, legacy_config_entry)
|
||||
|
||||
entity_entry = entity_registry.async_get(f"sensor.{object_id}")
|
||||
assert entity_entry.unit_of_measurement == expected_unit
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user