Use snapshot testing in NextDNS (#115879)

* Use snapshot testing in NextDNS sensor

* Use snapshot testing in NextDNS switch

* Use snapshot testing in NextDNS binary sensor

* Use snapshot testing in NextDNS button

---------

Co-authored-by: Maciej Bieniek <478555+bieniu@users.noreply.github.com>
This commit is contained in:
Maciej Bieniek 2024-04-20 12:31:20 +02:00 committed by GitHub
parent 354c20a57b
commit c8d52c02c5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 11880 additions and 883 deletions

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,47 @@
# serializer version: 1
# name: test_button[button.fake_profile_clear_logs-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'button',
'entity_category': <EntityCategory.CONFIG: 'config'>,
'entity_id': 'button.fake_profile_clear_logs',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Clear logs',
'platform': 'nextdns',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'clear_logs',
'unique_id': 'xyz12_clear_logs',
'unit_of_measurement': None,
})
# ---
# name: test_button[button.fake_profile_clear_logs-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Fake Profile Clear logs',
}),
'context': <ANY>,
'entity_id': 'button.fake_profile_clear_logs',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unknown',
})
# ---

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -4,8 +4,9 @@ from datetime import timedelta
from unittest.mock import patch
from nextdns import ApiError
from syrupy import SnapshotAssertion
from homeassistant.const import STATE_OFF, STATE_ON, STATE_UNAVAILABLE
from homeassistant.const import STATE_ON, STATE_UNAVAILABLE, Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from homeassistant.util.dt import utcnow
@ -15,31 +16,20 @@ from . import init_integration, mock_nextdns
from tests.common import async_fire_time_changed
async def test_binary_Sensor(hass: HomeAssistant) -> None:
async def test_binary_sensor(
hass: HomeAssistant, entity_registry: er.EntityRegistry, snapshot: SnapshotAssertion
) -> None:
"""Test states of the binary sensors."""
registry = er.async_get(hass)
with patch("homeassistant.components.nextdns.PLATFORMS", [Platform.BINARY_SENSOR]):
entry = await init_integration(hass)
await init_integration(hass)
entity_entries = er.async_entries_for_config_entry(entity_registry, entry.entry_id)
state = hass.states.get("binary_sensor.fake_profile_device_connection_status")
assert state
assert state.state == STATE_ON
entry = registry.async_get("binary_sensor.fake_profile_device_connection_status")
assert entry
assert entry.unique_id == "xyz12_this_device_nextdns_connection_status"
state = hass.states.get(
"binary_sensor.fake_profile_device_profile_connection_status"
)
assert state
assert state.state == STATE_OFF
entry = registry.async_get(
"binary_sensor.fake_profile_device_profile_connection_status"
)
assert entry
assert entry.unique_id == "xyz12_this_device_profile_connection_status"
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")
async def test_availability(hass: HomeAssistant) -> None:

View file

@ -2,8 +2,10 @@
from unittest.mock import patch
from syrupy import SnapshotAssertion
from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN
from homeassistant.const import ATTR_ENTITY_ID, STATE_UNKNOWN
from homeassistant.const import ATTR_ENTITY_ID, Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from homeassistant.util import dt as dt_util
@ -11,19 +13,20 @@ from homeassistant.util import dt as dt_util
from . import init_integration
async def test_button(hass: HomeAssistant) -> None:
async def test_button(
hass: HomeAssistant, entity_registry: er.EntityRegistry, snapshot: SnapshotAssertion
) -> None:
"""Test states of the button."""
registry = er.async_get(hass)
with patch("homeassistant.components.nextdns.PLATFORMS", [Platform.BUTTON]):
entry = await init_integration(hass)
await init_integration(hass)
entity_entries = er.async_entries_for_config_entry(entity_registry, entry.entry_id)
state = hass.states.get("button.fake_profile_clear_logs")
assert state
assert state.state == STATE_UNKNOWN
entry = registry.async_get("button.fake_profile_clear_logs")
assert entry
assert entry.unique_id == "xyz12_clear_logs"
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")
async def test_button_press(hass: HomeAssistant) -> None:

View file

@ -4,9 +4,9 @@ from datetime import timedelta
from unittest.mock import patch
from nextdns import ApiError
from syrupy import SnapshotAssertion
from homeassistant.components.sensor import ATTR_STATE_CLASS, SensorStateClass
from homeassistant.const import ATTR_UNIT_OF_MEASUREMENT, PERCENTAGE, STATE_UNAVAILABLE
from homeassistant.const import STATE_UNAVAILABLE, Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from homeassistant.util.dt import utcnow
@ -17,270 +17,30 @@ from tests.common import async_fire_time_changed
async def test_sensor(
hass: HomeAssistant, entity_registry_enabled_by_default: None
hass: HomeAssistant,
entity_registry_enabled_by_default: None,
entity_registry: er.EntityRegistry,
snapshot: SnapshotAssertion,
) -> None:
"""Test states of sensors."""
registry = er.async_get(hass)
with patch("homeassistant.components.nextdns.PLATFORMS", [Platform.SENSOR]):
entry = await init_integration(hass)
await init_integration(hass)
entity_entries = er.async_entries_for_config_entry(entity_registry, entry.entry_id)
state = hass.states.get("sensor.fake_profile_dns_queries")
assert state
assert state.state == "100"
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.TOTAL
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == "queries"
entry = registry.async_get("sensor.fake_profile_dns_queries")
assert entry
assert entry.unique_id == "xyz12_all_queries"
state = hass.states.get("sensor.fake_profile_dns_queries_blocked")
assert state
assert state.state == "20"
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.TOTAL
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == "queries"
entry = registry.async_get("sensor.fake_profile_dns_queries_blocked")
assert entry
assert entry.unique_id == "xyz12_blocked_queries"
state = hass.states.get("sensor.fake_profile_dns_queries_blocked_ratio")
assert state
assert state.state == "20.0"
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
entry = registry.async_get("sensor.fake_profile_dns_queries_blocked_ratio")
assert entry
assert entry.unique_id == "xyz12_blocked_queries_ratio"
state = hass.states.get("sensor.fake_profile_dns_queries_relayed")
assert state
assert state.state == "10"
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.TOTAL
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == "queries"
entry = registry.async_get("sensor.fake_profile_dns_queries_relayed")
assert entry
assert entry.unique_id == "xyz12_relayed_queries"
state = hass.states.get("sensor.fake_profile_dns_over_https_queries")
assert state
assert state.state == "20"
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.TOTAL
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == "queries"
entry = registry.async_get("sensor.fake_profile_dns_over_https_queries")
assert entry
assert entry.unique_id == "xyz12_doh_queries"
state = hass.states.get("sensor.fake_profile_dns_over_https_queries_ratio")
assert state
assert state.state == "17.4"
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
entry = registry.async_get("sensor.fake_profile_dns_over_https_queries_ratio")
assert entry
assert entry.unique_id == "xyz12_doh_queries_ratio"
state = hass.states.get("sensor.fake_profile_dns_over_http_3_queries")
assert state
assert state.state == "15"
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.TOTAL
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == "queries"
entry = registry.async_get("sensor.fake_profile_dns_over_http_3_queries")
assert entry
assert entry.unique_id == "xyz12_doh3_queries"
state = hass.states.get("sensor.fake_profile_dns_over_http_3_queries_ratio")
assert state
assert state.state == "13.0"
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
entry = registry.async_get("sensor.fake_profile_dns_over_http_3_queries_ratio")
assert entry
assert entry.unique_id == "xyz12_doh3_queries_ratio"
state = hass.states.get("sensor.fake_profile_dns_over_quic_queries")
assert state
assert state.state == "10"
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.TOTAL
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == "queries"
entry = registry.async_get("sensor.fake_profile_dns_over_quic_queries")
assert entry
assert entry.unique_id == "xyz12_doq_queries"
state = hass.states.get("sensor.fake_profile_dns_over_quic_queries_ratio")
assert state
assert state.state == "8.7"
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
entry = registry.async_get("sensor.fake_profile_dns_over_quic_queries_ratio")
assert entry
assert entry.unique_id == "xyz12_doq_queries_ratio"
state = hass.states.get("sensor.fake_profile_dns_over_tls_queries")
assert state
assert state.state == "30"
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.TOTAL
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == "queries"
entry = registry.async_get("sensor.fake_profile_dns_over_tls_queries")
assert entry
assert entry.unique_id == "xyz12_dot_queries"
state = hass.states.get("sensor.fake_profile_dns_over_tls_queries_ratio")
assert state
assert state.state == "26.1"
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
entry = registry.async_get("sensor.fake_profile_dns_over_tls_queries_ratio")
assert entry
assert entry.unique_id == "xyz12_dot_queries_ratio"
state = hass.states.get("sensor.fake_profile_dnssec_not_validated_queries")
assert state
assert state.state == "25"
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.TOTAL
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == "queries"
entry = registry.async_get("sensor.fake_profile_dnssec_not_validated_queries")
assert entry
assert entry.unique_id == "xyz12_not_validated_queries"
state = hass.states.get("sensor.fake_profile_dnssec_validated_queries")
assert state
assert state.state == "75"
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.TOTAL
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == "queries"
entry = registry.async_get("sensor.fake_profile_dnssec_validated_queries")
assert entry
assert entry.unique_id == "xyz12_validated_queries"
state = hass.states.get("sensor.fake_profile_dnssec_validated_queries_ratio")
assert state
assert state.state == "75.0"
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
entry = registry.async_get("sensor.fake_profile_dnssec_validated_queries_ratio")
assert entry
assert entry.unique_id == "xyz12_validated_queries_ratio"
state = hass.states.get("sensor.fake_profile_encrypted_queries")
assert state
assert state.state == "60"
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.TOTAL
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == "queries"
entry = registry.async_get("sensor.fake_profile_encrypted_queries")
assert entry
assert entry.unique_id == "xyz12_encrypted_queries"
state = hass.states.get("sensor.fake_profile_unencrypted_queries")
assert state
assert state.state == "40"
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.TOTAL
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == "queries"
entry = registry.async_get("sensor.fake_profile_unencrypted_queries")
assert entry
assert entry.unique_id == "xyz12_unencrypted_queries"
state = hass.states.get("sensor.fake_profile_encrypted_queries_ratio")
assert state
assert state.state == "60.0"
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
entry = registry.async_get("sensor.fake_profile_encrypted_queries_ratio")
assert entry
assert entry.unique_id == "xyz12_encrypted_queries_ratio"
state = hass.states.get("sensor.fake_profile_ipv4_queries")
assert state
assert state.state == "90"
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.TOTAL
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == "queries"
entry = registry.async_get("sensor.fake_profile_ipv4_queries")
assert entry
assert entry.unique_id == "xyz12_ipv4_queries"
state = hass.states.get("sensor.fake_profile_ipv6_queries")
assert state
assert state.state == "10"
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.TOTAL
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == "queries"
entry = registry.async_get("sensor.fake_profile_ipv6_queries")
assert entry
assert entry.unique_id == "xyz12_ipv6_queries"
state = hass.states.get("sensor.fake_profile_ipv6_queries_ratio")
assert state
assert state.state == "10.0"
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
entry = registry.async_get("sensor.fake_profile_ipv6_queries_ratio")
assert entry
assert entry.unique_id == "xyz12_ipv6_queries_ratio"
state = hass.states.get("sensor.fake_profile_tcp_queries")
assert state
assert state.state == "0"
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.TOTAL
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == "queries"
entry = registry.async_get("sensor.fake_profile_tcp_queries")
assert entry
assert entry.unique_id == "xyz12_tcp_queries"
state = hass.states.get("sensor.fake_profile_tcp_queries_ratio")
assert state
assert state.state == "0.0"
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
entry = registry.async_get("sensor.fake_profile_tcp_queries_ratio")
assert entry
assert entry.unique_id == "xyz12_tcp_queries_ratio"
state = hass.states.get("sensor.fake_profile_udp_queries")
assert state
assert state.state == "40"
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.TOTAL
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == "queries"
entry = registry.async_get("sensor.fake_profile_udp_queries")
assert entry
assert entry.unique_id == "xyz12_udp_queries"
state = hass.states.get("sensor.fake_profile_udp_queries_ratio")
assert state
assert state.state == "34.8"
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
entry = registry.async_get("sensor.fake_profile_udp_queries_ratio")
assert entry
assert entry.unique_id == "xyz12_udp_queries_ratio"
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")
async def test_availability(
hass: HomeAssistant, entity_registry_enabled_by_default: None
hass: HomeAssistant,
entity_registry_enabled_by_default: None,
entity_registry: er.EntityRegistry,
) -> None:
"""Ensure that we mark the entities unavailable correctly when service causes an error."""
er.async_get(hass)
await init_integration(hass)
state = hass.states.get("sensor.fake_profile_dns_queries")

View file

@ -7,6 +7,7 @@ from aiohttp import ClientError
from aiohttp.client_exceptions import ClientConnectorError
from nextdns import ApiError
import pytest
from syrupy import SnapshotAssertion
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
from homeassistant.const import (
@ -16,6 +17,7 @@ from homeassistant.const import (
STATE_OFF,
STATE_ON,
STATE_UNAVAILABLE,
Platform,
)
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
@ -28,602 +30,22 @@ from tests.common import async_fire_time_changed
async def test_switch(
hass: HomeAssistant, entity_registry_enabled_by_default: None
hass: HomeAssistant,
entity_registry_enabled_by_default: None,
entity_registry: er.EntityRegistry,
snapshot: SnapshotAssertion,
) -> None:
"""Test states of the switches."""
registry = er.async_get(hass)
with patch("homeassistant.components.nextdns.PLATFORMS", [Platform.SWITCH]):
entry = await init_integration(hass)
await init_integration(hass)
entity_entries = er.async_entries_for_config_entry(entity_registry, entry.entry_id)
state = hass.states.get("switch.fake_profile_ai_driven_threat_detection")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_ai_driven_threat_detection")
assert entry
assert entry.unique_id == "xyz12_ai_threat_detection"
state = hass.states.get("switch.fake_profile_allow_affiliate_tracking_links")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_allow_affiliate_tracking_links")
assert entry
assert entry.unique_id == "xyz12_allow_affiliate"
state = hass.states.get("switch.fake_profile_anonymized_edns_client_subnet")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_anonymized_edns_client_subnet")
assert entry
assert entry.unique_id == "xyz12_anonymized_ecs"
state = hass.states.get("switch.fake_profile_block_bypass_methods")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_bypass_methods")
assert entry
assert entry.unique_id == "xyz12_block_bypass_methods"
state = hass.states.get("switch.fake_profile_block_child_sexual_abuse_material")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_child_sexual_abuse_material")
assert entry
assert entry.unique_id == "xyz12_block_csam"
state = hass.states.get("switch.fake_profile_block_disguised_third_party_trackers")
assert state
assert state.state == STATE_ON
entry = registry.async_get(
"switch.fake_profile_block_disguised_third_party_trackers"
)
assert entry
assert entry.unique_id == "xyz12_block_disguised_trackers"
state = hass.states.get("switch.fake_profile_block_dynamic_dns_hostnames")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_dynamic_dns_hostnames")
assert entry
assert entry.unique_id == "xyz12_block_ddns"
state = hass.states.get("switch.fake_profile_block_newly_registered_domains")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_newly_registered_domains")
assert entry
assert entry.unique_id == "xyz12_block_nrd"
state = hass.states.get("switch.fake_profile_block_page")
assert state
assert state.state == STATE_OFF
entry = registry.async_get("switch.fake_profile_block_page")
assert entry
assert entry.unique_id == "xyz12_block_page"
state = hass.states.get("switch.fake_profile_block_parked_domains")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_parked_domains")
assert entry
assert entry.unique_id == "xyz12_block_parked_domains"
state = hass.states.get("switch.fake_profile_cname_flattening")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_cname_flattening")
assert entry
assert entry.unique_id == "xyz12_cname_flattening"
state = hass.states.get("switch.fake_profile_cache_boost")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_cache_boost")
assert entry
assert entry.unique_id == "xyz12_cache_boost"
state = hass.states.get("switch.fake_profile_cryptojacking_protection")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_cryptojacking_protection")
assert entry
assert entry.unique_id == "xyz12_cryptojacking_protection"
state = hass.states.get("switch.fake_profile_dns_rebinding_protection")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_dns_rebinding_protection")
assert entry
assert entry.unique_id == "xyz12_dns_rebinding_protection"
state = hass.states.get(
"switch.fake_profile_domain_generation_algorithms_protection"
)
assert state
assert state.state == STATE_ON
entry = registry.async_get(
"switch.fake_profile_domain_generation_algorithms_protection"
)
assert entry
assert entry.unique_id == "xyz12_dga_protection"
state = hass.states.get("switch.fake_profile_force_safesearch")
assert state
assert state.state == STATE_OFF
entry = registry.async_get("switch.fake_profile_force_safesearch")
assert entry
assert entry.unique_id == "xyz12_safesearch"
state = hass.states.get("switch.fake_profile_force_youtube_restricted_mode")
assert state
assert state.state == STATE_OFF
entry = registry.async_get("switch.fake_profile_force_youtube_restricted_mode")
assert entry
assert entry.unique_id == "xyz12_youtube_restricted_mode"
state = hass.states.get("switch.fake_profile_google_safe_browsing")
assert state
assert state.state == STATE_OFF
entry = registry.async_get("switch.fake_profile_google_safe_browsing")
assert entry
assert entry.unique_id == "xyz12_google_safe_browsing"
state = hass.states.get("switch.fake_profile_idn_homograph_attacks_protection")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_idn_homograph_attacks_protection")
assert entry
assert entry.unique_id == "xyz12_idn_homograph_attacks_protection"
state = hass.states.get("switch.fake_profile_logs")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_logs")
assert entry
assert entry.unique_id == "xyz12_logs"
state = hass.states.get("switch.fake_profile_threat_intelligence_feeds")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_threat_intelligence_feeds")
assert entry
assert entry.unique_id == "xyz12_threat_intelligence_feeds"
state = hass.states.get("switch.fake_profile_typosquatting_protection")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_typosquatting_protection")
assert entry
assert entry.unique_id == "xyz12_typosquatting_protection"
state = hass.states.get("switch.fake_profile_web3")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_web3")
assert entry
assert entry.unique_id == "xyz12_web3"
state = hass.states.get("switch.fake_profile_block_9gag")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_9gag")
assert entry
assert entry.unique_id == "xyz12_block_9gag"
state = hass.states.get("switch.fake_profile_block_amazon")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_amazon")
assert entry
assert entry.unique_id == "xyz12_block_amazon"
state = hass.states.get("switch.fake_profile_block_bereal")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_bereal")
assert entry
assert entry.unique_id == "xyz12_block_bereal"
state = hass.states.get("switch.fake_profile_block_blizzard")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_blizzard")
assert entry
assert entry.unique_id == "xyz12_block_blizzard"
state = hass.states.get("switch.fake_profile_block_chatgpt")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_chatgpt")
assert entry
assert entry.unique_id == "xyz12_block_chatgpt"
state = hass.states.get("switch.fake_profile_block_dailymotion")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_dailymotion")
assert entry
assert entry.unique_id == "xyz12_block_dailymotion"
state = hass.states.get("switch.fake_profile_block_discord")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_discord")
assert entry
assert entry.unique_id == "xyz12_block_discord"
state = hass.states.get("switch.fake_profile_block_disney_plus")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_disney_plus")
assert entry
assert entry.unique_id == "xyz12_block_disneyplus"
state = hass.states.get("switch.fake_profile_block_ebay")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_ebay")
assert entry
assert entry.unique_id == "xyz12_block_ebay"
state = hass.states.get("switch.fake_profile_block_facebook")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_facebook")
assert entry
assert entry.unique_id == "xyz12_block_facebook"
state = hass.states.get("switch.fake_profile_block_fortnite")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_fortnite")
assert entry
assert entry.unique_id == "xyz12_block_fortnite"
state = hass.states.get("switch.fake_profile_block_google_chat")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_google_chat")
assert entry
assert entry.unique_id == "xyz12_block_google_chat"
state = hass.states.get("switch.fake_profile_block_hbo_max")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_hbo_max")
assert entry
assert entry.unique_id == "xyz12_block_hbomax"
state = hass.states.get("switch.fake_profile_block_hulu")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_hulu")
assert entry
assert entry.unique_id == "xyz12_block_hulu"
state = hass.states.get("switch.fake_profile_block_imgur")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_imgur")
assert entry
assert entry.unique_id == "xyz12_block_imgur"
state = hass.states.get("switch.fake_profile_block_instagram")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_instagram")
assert entry
assert entry.unique_id == "xyz12_block_instagram"
state = hass.states.get("switch.fake_profile_block_league_of_legends")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_league_of_legends")
assert entry
assert entry.unique_id == "xyz12_block_leagueoflegends"
state = hass.states.get("switch.fake_profile_block_mastodon")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_mastodon")
assert entry
assert entry.unique_id == "xyz12_block_mastodon"
state = hass.states.get("switch.fake_profile_block_messenger")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_messenger")
assert entry
assert entry.unique_id == "xyz12_block_messenger"
state = hass.states.get("switch.fake_profile_block_minecraft")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_minecraft")
assert entry
assert entry.unique_id == "xyz12_block_minecraft"
state = hass.states.get("switch.fake_profile_block_netflix")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_netflix")
assert entry
assert entry.unique_id == "xyz12_block_netflix"
state = hass.states.get("switch.fake_profile_block_pinterest")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_pinterest")
assert entry
assert entry.unique_id == "xyz12_block_pinterest"
state = hass.states.get("switch.fake_profile_block_playstation_network")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_playstation_network")
assert entry
assert entry.unique_id == "xyz12_block_playstation_network"
state = hass.states.get("switch.fake_profile_block_prime_video")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_prime_video")
assert entry
assert entry.unique_id == "xyz12_block_primevideo"
state = hass.states.get("switch.fake_profile_block_reddit")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_reddit")
assert entry
assert entry.unique_id == "xyz12_block_reddit"
state = hass.states.get("switch.fake_profile_block_roblox")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_roblox")
assert entry
assert entry.unique_id == "xyz12_block_roblox"
state = hass.states.get("switch.fake_profile_block_signal")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_signal")
assert entry
assert entry.unique_id == "xyz12_block_signal"
state = hass.states.get("switch.fake_profile_block_skype")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_skype")
assert entry
assert entry.unique_id == "xyz12_block_skype"
state = hass.states.get("switch.fake_profile_block_snapchat")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_snapchat")
assert entry
assert entry.unique_id == "xyz12_block_snapchat"
state = hass.states.get("switch.fake_profile_block_spotify")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_spotify")
assert entry
assert entry.unique_id == "xyz12_block_spotify"
state = hass.states.get("switch.fake_profile_block_steam")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_steam")
assert entry
assert entry.unique_id == "xyz12_block_steam"
state = hass.states.get("switch.fake_profile_block_telegram")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_telegram")
assert entry
assert entry.unique_id == "xyz12_block_telegram"
state = hass.states.get("switch.fake_profile_block_tiktok")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_tiktok")
assert entry
assert entry.unique_id == "xyz12_block_tiktok"
state = hass.states.get("switch.fake_profile_block_tinder")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_tinder")
assert entry
assert entry.unique_id == "xyz12_block_tinder"
state = hass.states.get("switch.fake_profile_block_tumblr")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_tumblr")
assert entry
assert entry.unique_id == "xyz12_block_tumblr"
state = hass.states.get("switch.fake_profile_block_twitch")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_twitch")
assert entry
assert entry.unique_id == "xyz12_block_twitch"
state = hass.states.get("switch.fake_profile_block_x_formerly_twitter")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_x_formerly_twitter")
assert entry
assert entry.unique_id == "xyz12_block_twitter"
state = hass.states.get("switch.fake_profile_block_vimeo")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_vimeo")
assert entry
assert entry.unique_id == "xyz12_block_vimeo"
state = hass.states.get("switch.fake_profile_block_vk")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_vk")
assert entry
assert entry.unique_id == "xyz12_block_vk"
state = hass.states.get("switch.fake_profile_block_whatsapp")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_whatsapp")
assert entry
assert entry.unique_id == "xyz12_block_whatsapp"
state = hass.states.get("switch.fake_profile_block_xbox_live")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_xbox_live")
assert entry
assert entry.unique_id == "xyz12_block_xboxlive"
state = hass.states.get("switch.fake_profile_block_youtube")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_youtube")
assert entry
assert entry.unique_id == "xyz12_block_youtube"
state = hass.states.get("switch.fake_profile_block_zoom")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_zoom")
assert entry
assert entry.unique_id == "xyz12_block_zoom"
state = hass.states.get("switch.fake_profile_block_dating")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_dating")
assert entry
assert entry.unique_id == "xyz12_block_dating"
state = hass.states.get("switch.fake_profile_block_gambling")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_gambling")
assert entry
assert entry.unique_id == "xyz12_block_gambling"
state = hass.states.get("switch.fake_profile_block_online_gaming")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_online_gaming")
assert entry
assert entry.unique_id == "xyz12_block_online_gaming"
state = hass.states.get("switch.fake_profile_block_piracy")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_piracy")
assert entry
assert entry.unique_id == "xyz12_block_piracy"
state = hass.states.get("switch.fake_profile_block_porn")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_porn")
assert entry
assert entry.unique_id == "xyz12_block_porn"
state = hass.states.get("switch.fake_profile_block_social_networks")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_social_networks")
assert entry
assert entry.unique_id == "xyz12_block_social_networks"
state = hass.states.get("switch.fake_profile_block_video_streaming")
assert state
assert state.state == STATE_ON
entry = registry.async_get("switch.fake_profile_block_video_streaming")
assert entry
assert entry.unique_id == "xyz12_block_video_streaming"
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")
async def test_switch_on(hass: HomeAssistant) -> None: