Use snapshot test helper in Husqvarna Automower (#116039)

This commit is contained in:
Thomas55555 2024-04-23 17:39:29 +02:00 committed by GitHub
parent 8257af1b22
commit d4b801af32
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 15 additions and 47 deletions

View file

@ -20,6 +20,7 @@ from tests.common import (
MockConfigEntry,
async_fire_time_changed,
load_json_value_fixture,
snapshot_platform,
)
@ -71,13 +72,6 @@ async def test_snapshot_binary_sensor(
[Platform.BINARY_SENSOR],
):
await setup_integration(hass, mock_config_entry)
entity_entries = er.async_entries_for_config_entry(
entity_registry, mock_config_entry.entry_id
await snapshot_platform(
hass, entity_registry, snapshot, mock_config_entry.entry_id
)
assert entity_entries
for entity_entry in entity_entries:
assert hass.states.get(entity_entry.entity_id) == snapshot(
name=f"{entity_entry.entity_id}-state"
)
assert entity_entry == snapshot(name=f"{entity_entry.entity_id}-entry")

View file

@ -10,7 +10,7 @@ from homeassistant.helpers import entity_registry as er
from . import setup_integration
from tests.common import MockConfigEntry
from tests.common import MockConfigEntry, snapshot_platform
async def test_device_tracker_snapshot(
@ -26,13 +26,6 @@ async def test_device_tracker_snapshot(
[Platform.DEVICE_TRACKER],
):
await setup_integration(hass, mock_config_entry)
entity_entries = er.async_entries_for_config_entry(
entity_registry, mock_config_entry.entry_id
await snapshot_platform(
hass, entity_registry, snapshot, mock_config_entry.entry_id
)
assert entity_entries
for entity_entry in entity_entries:
assert hass.states.get(entity_entry.entity_id) == snapshot(
name=f"{entity_entry.entity_id}-state"
)
assert entity_entry == snapshot(name=f"{entity_entry.entity_id}-entry")

View file

@ -13,7 +13,7 @@ from homeassistant.helpers import entity_registry as er
from . import setup_integration
from tests.common import MockConfigEntry
from tests.common import MockConfigEntry, snapshot_platform
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
@ -65,13 +65,6 @@ async def test_snapshot_number(
[Platform.NUMBER],
):
await setup_integration(hass, mock_config_entry)
entity_entries = er.async_entries_for_config_entry(
entity_registry, mock_config_entry.entry_id
await snapshot_platform(
hass, entity_registry, snapshot, mock_config_entry.entry_id
)
assert entity_entries
for entity_entry in entity_entries:
assert hass.states.get(entity_entry.entity_id) == snapshot(
name=f"{entity_entry.entity_id}-state"
)
assert entity_entry == snapshot(name=f"{entity_entry.entity_id}-entry")

View file

@ -21,6 +21,7 @@ from tests.common import (
MockConfigEntry,
async_fire_time_changed,
load_json_value_fixture,
snapshot_platform,
)
@ -132,13 +133,6 @@ async def test_sensor(
[Platform.SENSOR],
):
await setup_integration(hass, mock_config_entry)
entity_entries = er.async_entries_for_config_entry(
entity_registry, mock_config_entry.entry_id
await snapshot_platform(
hass, entity_registry, snapshot, mock_config_entry.entry_id
)
assert entity_entries
for entity_entry in entity_entries:
assert hass.states.get(entity_entry.entity_id) == snapshot(
name=f"{entity_entry.entity_id}-state"
)
assert entity_entry == snapshot(name=f"{entity_entry.entity_id}-entry")

View file

@ -23,6 +23,7 @@ from tests.common import (
MockConfigEntry,
async_fire_time_changed,
load_json_value_fixture,
snapshot_platform,
)
@ -106,13 +107,6 @@ async def test_switch(
[Platform.SWITCH],
):
await setup_integration(hass, mock_config_entry)
entity_entries = er.async_entries_for_config_entry(
entity_registry, mock_config_entry.entry_id
await snapshot_platform(
hass, entity_registry, snapshot, mock_config_entry.entry_id
)
assert entity_entries
for entity_entry in entity_entries:
assert hass.states.get(entity_entry.entity_id) == snapshot(
name=f"{entity_entry.entity_id}-state"
)
assert entity_entry == snapshot(name=f"{entity_entry.entity_id}-entry")