Use snapshot test helper in NextDNS (#115895)

Co-authored-by: Maciej Bieniek <478555+bieniu@users.noreply.github.com>
This commit is contained in:
Maciej Bieniek 2024-04-20 18:43:40 +02:00 committed by GitHub
parent 5e345b7129
commit 10be2cc004
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 9 additions and 31 deletions

View File

@ -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:

View File

@ -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:

View File

@ -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(

View File

@ -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: