mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 17:27:10 +00:00
Use snapshot test helper in NextDNS (#115895)
Co-authored-by: Maciej Bieniek <478555+bieniu@users.noreply.github.com>
This commit is contained in:
parent
5e345b7129
commit
10be2cc004
@ -13,7 +13,7 @@ from homeassistant.util.dt import utcnow
|
||||
|
||||
from . import init_integration, mock_nextdns
|
||||
|
||||
from tests.common import async_fire_time_changed
|
||||
from tests.common import async_fire_time_changed, snapshot_platform
|
||||
|
||||
|
||||
async def test_binary_sensor(
|
||||
@ -23,13 +23,7 @@ async def test_binary_sensor(
|
||||
with patch("homeassistant.components.nextdns.PLATFORMS", [Platform.BINARY_SENSOR]):
|
||||
entry = await init_integration(hass)
|
||||
|
||||
entity_entries = er.async_entries_for_config_entry(entity_registry, entry.entry_id)
|
||||
|
||||
assert entity_entries
|
||||
for entity_entry in entity_entries:
|
||||
assert entity_entry == snapshot(name=f"{entity_entry.entity_id}-entry")
|
||||
assert (state := hass.states.get(entity_entry.entity_id))
|
||||
assert state == snapshot(name=f"{entity_entry.entity_id}-state")
|
||||
await snapshot_platform(hass, entity_registry, snapshot, entry.entry_id)
|
||||
|
||||
|
||||
async def test_availability(hass: HomeAssistant) -> None:
|
||||
|
@ -12,6 +12,8 @@ from homeassistant.util import dt as dt_util
|
||||
|
||||
from . import init_integration
|
||||
|
||||
from tests.common import snapshot_platform
|
||||
|
||||
|
||||
async def test_button(
|
||||
hass: HomeAssistant, entity_registry: er.EntityRegistry, snapshot: SnapshotAssertion
|
||||
@ -20,13 +22,7 @@ async def test_button(
|
||||
with patch("homeassistant.components.nextdns.PLATFORMS", [Platform.BUTTON]):
|
||||
entry = await init_integration(hass)
|
||||
|
||||
entity_entries = er.async_entries_for_config_entry(entity_registry, entry.entry_id)
|
||||
|
||||
assert entity_entries
|
||||
for entity_entry in entity_entries:
|
||||
assert entity_entry == snapshot(name=f"{entity_entry.entity_id}-entry")
|
||||
assert (state := hass.states.get(entity_entry.entity_id))
|
||||
assert state == snapshot(name=f"{entity_entry.entity_id}-state")
|
||||
await snapshot_platform(hass, entity_registry, snapshot, entry.entry_id)
|
||||
|
||||
|
||||
async def test_button_press(hass: HomeAssistant) -> None:
|
||||
|
@ -13,7 +13,7 @@ from homeassistant.util.dt import utcnow
|
||||
|
||||
from . import init_integration, mock_nextdns
|
||||
|
||||
from tests.common import async_fire_time_changed
|
||||
from tests.common import async_fire_time_changed, snapshot_platform
|
||||
|
||||
|
||||
async def test_sensor(
|
||||
@ -26,13 +26,7 @@ async def test_sensor(
|
||||
with patch("homeassistant.components.nextdns.PLATFORMS", [Platform.SENSOR]):
|
||||
entry = await init_integration(hass)
|
||||
|
||||
entity_entries = er.async_entries_for_config_entry(entity_registry, entry.entry_id)
|
||||
|
||||
assert entity_entries
|
||||
for entity_entry in entity_entries:
|
||||
assert entity_entry == snapshot(name=f"{entity_entry.entity_id}-entry")
|
||||
assert (state := hass.states.get(entity_entry.entity_id))
|
||||
assert state == snapshot(name=f"{entity_entry.entity_id}-state")
|
||||
await snapshot_platform(hass, entity_registry, snapshot, entry.entry_id)
|
||||
|
||||
|
||||
async def test_availability(
|
||||
|
@ -26,7 +26,7 @@ from homeassistant.util.dt import utcnow
|
||||
|
||||
from . import init_integration, mock_nextdns
|
||||
|
||||
from tests.common import async_fire_time_changed
|
||||
from tests.common import async_fire_time_changed, snapshot_platform
|
||||
|
||||
|
||||
async def test_switch(
|
||||
@ -39,13 +39,7 @@ async def test_switch(
|
||||
with patch("homeassistant.components.nextdns.PLATFORMS", [Platform.SWITCH]):
|
||||
entry = await init_integration(hass)
|
||||
|
||||
entity_entries = er.async_entries_for_config_entry(entity_registry, entry.entry_id)
|
||||
|
||||
assert entity_entries
|
||||
for entity_entry in entity_entries:
|
||||
assert entity_entry == snapshot(name=f"{entity_entry.entity_id}-entry")
|
||||
assert (state := hass.states.get(entity_entry.entity_id))
|
||||
assert state == snapshot(name=f"{entity_entry.entity_id}-state")
|
||||
await snapshot_platform(hass, entity_registry, snapshot, entry.entry_id)
|
||||
|
||||
|
||||
async def test_switch_on(hass: HomeAssistant) -> None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user