Use registry fixtures in tests (s) (#118295)
This commit is contained in:
parent
90500c4b97
commit
e58d060f82
56 changed files with 377 additions and 318 deletions
|
@ -603,6 +603,7 @@ async def test_restore_sensor_restore_state(
|
|||
)
|
||||
async def test_custom_unit(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
device_class,
|
||||
native_unit,
|
||||
custom_unit,
|
||||
|
@ -611,8 +612,6 @@ async def test_custom_unit(
|
|||
custom_state,
|
||||
) -> None:
|
||||
"""Test custom unit."""
|
||||
entity_registry = er.async_get(hass)
|
||||
|
||||
entry = entity_registry.async_get_or_create("sensor", "test", "very_unique")
|
||||
entity_registry.async_update_entity_options(
|
||||
entry.entity_id, "sensor", {"unit_of_measurement": custom_unit}
|
||||
|
@ -863,6 +862,7 @@ async def test_custom_unit(
|
|||
)
|
||||
async def test_custom_unit_change(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
native_unit,
|
||||
custom_unit,
|
||||
state_unit,
|
||||
|
@ -872,7 +872,6 @@ async def test_custom_unit_change(
|
|||
device_class,
|
||||
) -> None:
|
||||
"""Test custom unit changes are picked up."""
|
||||
entity_registry = er.async_get(hass)
|
||||
entity0 = MockSensor(
|
||||
name="Test",
|
||||
native_value=str(native_value),
|
||||
|
@ -948,6 +947,7 @@ async def test_custom_unit_change(
|
|||
)
|
||||
async def test_unit_conversion_priority(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
unit_system,
|
||||
native_unit,
|
||||
automatic_unit,
|
||||
|
@ -964,8 +964,6 @@ async def test_unit_conversion_priority(
|
|||
|
||||
hass.config.units = unit_system
|
||||
|
||||
entity_registry = er.async_get(hass)
|
||||
|
||||
entity0 = MockSensor(
|
||||
name="Test",
|
||||
device_class=device_class,
|
||||
|
@ -1095,6 +1093,7 @@ async def test_unit_conversion_priority(
|
|||
)
|
||||
async def test_unit_conversion_priority_precision(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
unit_system,
|
||||
native_unit,
|
||||
automatic_unit,
|
||||
|
@ -1112,8 +1111,6 @@ async def test_unit_conversion_priority_precision(
|
|||
|
||||
hass.config.units = unit_system
|
||||
|
||||
entity_registry = er.async_get(hass)
|
||||
|
||||
entity0 = MockSensor(
|
||||
name="Test",
|
||||
device_class=device_class,
|
||||
|
@ -1280,6 +1277,7 @@ async def test_unit_conversion_priority_precision(
|
|||
)
|
||||
async def test_unit_conversion_priority_suggested_unit_change(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
unit_system,
|
||||
native_unit,
|
||||
original_unit,
|
||||
|
@ -1292,8 +1290,6 @@ async def test_unit_conversion_priority_suggested_unit_change(
|
|||
|
||||
hass.config.units = unit_system
|
||||
|
||||
entity_registry = er.async_get(hass)
|
||||
|
||||
# Pre-register entities
|
||||
entry = entity_registry.async_get_or_create(
|
||||
"sensor", "test", "very_unique", unit_of_measurement=original_unit
|
||||
|
@ -1387,6 +1383,7 @@ async def test_unit_conversion_priority_suggested_unit_change(
|
|||
)
|
||||
async def test_unit_conversion_priority_suggested_unit_change_2(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
native_unit_1,
|
||||
native_unit_2,
|
||||
suggested_unit,
|
||||
|
@ -1398,8 +1395,6 @@ async def test_unit_conversion_priority_suggested_unit_change_2(
|
|||
|
||||
hass.config.units = METRIC_SYSTEM
|
||||
|
||||
entity_registry = er.async_get(hass)
|
||||
|
||||
# Pre-register entities
|
||||
entity_registry.async_get_or_create(
|
||||
"sensor", "test", "very_unique", unit_of_measurement=native_unit_1
|
||||
|
@ -1486,6 +1481,7 @@ async def test_unit_conversion_priority_suggested_unit_change_2(
|
|||
)
|
||||
async def test_suggested_precision_option(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
unit_system,
|
||||
native_unit,
|
||||
integration_suggested_precision,
|
||||
|
@ -1498,7 +1494,6 @@ async def test_suggested_precision_option(
|
|||
|
||||
hass.config.units = unit_system
|
||||
|
||||
entity_registry = er.async_get(hass)
|
||||
entity0 = MockSensor(
|
||||
name="Test",
|
||||
device_class=device_class,
|
||||
|
@ -1560,6 +1555,7 @@ async def test_suggested_precision_option(
|
|||
)
|
||||
async def test_suggested_precision_option_update(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
unit_system,
|
||||
native_unit,
|
||||
suggested_unit,
|
||||
|
@ -1574,8 +1570,6 @@ async def test_suggested_precision_option_update(
|
|||
|
||||
hass.config.units = unit_system
|
||||
|
||||
entity_registry = er.async_get(hass)
|
||||
|
||||
# Pre-register entities
|
||||
entry = entity_registry.async_get_or_create("sensor", "test", "very_unique")
|
||||
entity_registry.async_update_entity_options(
|
||||
|
@ -1620,11 +1614,9 @@ async def test_suggested_precision_option_update(
|
|||
|
||||
async def test_suggested_precision_option_removal(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
) -> None:
|
||||
"""Test suggested precision stored in the registry is removed."""
|
||||
|
||||
entity_registry = er.async_get(hass)
|
||||
|
||||
# Pre-register entities
|
||||
entry = entity_registry.async_get_or_create("sensor", "test", "very_unique")
|
||||
entity_registry.async_update_entity_options(
|
||||
|
@ -1684,6 +1676,7 @@ async def test_suggested_precision_option_removal(
|
|||
)
|
||||
async def test_unit_conversion_priority_legacy_conversion_removed(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
unit_system,
|
||||
native_unit,
|
||||
original_unit,
|
||||
|
@ -1695,8 +1688,6 @@ async def test_unit_conversion_priority_legacy_conversion_removed(
|
|||
|
||||
hass.config.units = unit_system
|
||||
|
||||
entity_registry = er.async_get(hass)
|
||||
|
||||
# Pre-register entities
|
||||
entity_registry.async_get_or_create(
|
||||
"sensor", "test", "very_unique", unit_of_measurement=original_unit
|
||||
|
@ -2187,6 +2178,7 @@ async def test_numeric_state_expected_helper(
|
|||
)
|
||||
async def test_unit_conversion_update(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
unit_system_1,
|
||||
unit_system_2,
|
||||
native_unit,
|
||||
|
@ -2205,8 +2197,6 @@ async def test_unit_conversion_update(
|
|||
|
||||
hass.config.units = unit_system_1
|
||||
|
||||
entity_registry = er.async_get(hass)
|
||||
|
||||
entity0 = MockSensor(
|
||||
name="Test 0",
|
||||
device_class=device_class,
|
||||
|
@ -2491,13 +2481,12 @@ def test_async_rounded_state_unregistered_entity_is_passthrough(
|
|||
|
||||
def test_async_rounded_state_registered_entity_with_display_precision(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
) -> None:
|
||||
"""Test async_rounded_state on registered with display precision.
|
||||
|
||||
The -0 should be dropped.
|
||||
"""
|
||||
entity_registry = er.async_get(hass)
|
||||
|
||||
entry = entity_registry.async_get_or_create("sensor", "test", "very_unique")
|
||||
entity_registry.async_update_entity_options(
|
||||
entry.entity_id,
|
||||
|
@ -2618,6 +2607,7 @@ def test_deprecated_constants_sensor_device_class(
|
|||
)
|
||||
async def test_suggested_unit_guard_invalid_unit(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
device_class: SensorDeviceClass,
|
||||
native_unit: str,
|
||||
|
@ -2626,8 +2616,6 @@ async def test_suggested_unit_guard_invalid_unit(
|
|||
|
||||
An invalid suggested unit creates a log entry and the suggested unit will be ignored.
|
||||
"""
|
||||
entity_registry = er.async_get(hass)
|
||||
|
||||
state_value = 10
|
||||
invalid_suggested_unit = "invalid_unit"
|
||||
|
||||
|
@ -2685,6 +2673,7 @@ async def test_suggested_unit_guard_invalid_unit(
|
|||
)
|
||||
async def test_suggested_unit_guard_valid_unit(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
device_class: SensorDeviceClass,
|
||||
native_unit: str,
|
||||
native_value: int,
|
||||
|
@ -2696,8 +2685,6 @@ async def test_suggested_unit_guard_valid_unit(
|
|||
Suggested unit is valid and therefore should be used for unit conversion and stored
|
||||
in the entity registry.
|
||||
"""
|
||||
entity_registry = er.async_get(hass)
|
||||
|
||||
entity = MockSensor(
|
||||
name="Valid",
|
||||
device_class=device_class,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue