Add snapshot tests to Netatmo platforms (#107932)

* Add snapshot tests to Netatmo platforms

* Add snapshot tests to Netatmo platforms
This commit is contained in:
Joost Lekkerkerker 2024-01-13 10:18:21 +01:00 committed by GitHub
parent 0458bd68d9
commit 902619a4db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 7211 additions and 10 deletions

View File

@ -4,12 +4,15 @@ import json
from typing import Any
from unittest.mock import AsyncMock, patch
from syrupy import SnapshotAssertion
from homeassistant.components.webhook import async_handle_webhook
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
import homeassistant.helpers.entity_registry as er
from homeassistant.util.aiohttp import MockRequest
from tests.common import load_fixture
from tests.common import MockConfigEntry, load_fixture
from tests.test_util.aiohttp import AiohttpClientMockResponse
COMMON_RESPONSE = {
@ -24,6 +27,30 @@ FAKE_WEBHOOK_ACTIVATION = {
}
async def snapshot_platform_entities(
hass: HomeAssistant,
config_entry: MockConfigEntry,
platform: Platform,
entity_registry: er.EntityRegistry,
snapshot: SnapshotAssertion,
) -> None:
"""Snapshot entities and their states."""
with selected_platforms([platform]):
assert await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
entity_entries = er.async_entries_for_config_entry(
entity_registry, config_entry.entry_id
)
assert entity_entries
for entity_entry in entity_entries:
assert entity_entry == snapshot(name=f"{entity_entry.entity_id}-entry")
assert hass.states.get(entity_entry.entity_id) == snapshot(
name=f"{entity_entry.entity_id}-state"
)
async def fake_post_request(*args: Any, **kwargs: Any):
"""Return fake data."""
if "endpoint" not in kwargs:

View File

@ -0,0 +1,173 @@
# serializer version: 1
# name: test_entity[camera.front-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'camera',
'entity_category': None,
'entity_id': 'camera.front',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': None,
'platform': 'netatmo',
'previous_unique_id': None,
'supported_features': <CameraEntityFeature: 3>,
'translation_key': None,
'unique_id': '12:34:56:10:b9:0e-DeviceType.NOC',
'unit_of_measurement': None,
})
# ---
# name: test_entity[camera.front-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'access_token': '1caab5c3b3',
'alim_status': 2,
'attribution': 'Data provided by Netatmo',
'brand': 'Netatmo',
'entity_picture': '/api/camera_proxy/camera.front?token=1caab5c3b3',
'friendly_name': 'Front',
'frontend_stream_type': <StreamType.HLS: 'hls'>,
'id': '12:34:56:10:b9:0e',
'is_local': False,
'light_state': None,
'local_url': None,
'monitoring': None,
'motion_detection': True,
'sd_status': 4,
'supported_features': <CameraEntityFeature: 3>,
'vpn_url': 'https://prodvpn-eu-6.netatmo.net/10.20.30.41/333333333333/444444444444,,',
}),
'context': <ANY>,
'entity_id': 'camera.front',
'last_changed': <ANY>,
'last_updated': <ANY>,
'state': 'streaming',
})
# ---
# name: test_entity[camera.hall-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'camera',
'entity_category': None,
'entity_id': 'camera.hall',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': None,
'platform': 'netatmo',
'previous_unique_id': None,
'supported_features': <CameraEntityFeature: 3>,
'translation_key': None,
'unique_id': '12:34:56:00:f1:62-DeviceType.NACamera',
'unit_of_measurement': None,
})
# ---
# name: test_entity[camera.hall-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'access_token': '1caab5c3b3',
'alim_status': 2,
'attribution': 'Data provided by Netatmo',
'brand': 'Netatmo',
'entity_picture': '/api/camera_proxy/camera.hall?token=1caab5c3b3',
'friendly_name': 'Hall',
'frontend_stream_type': <StreamType.HLS: 'hls'>,
'id': '12:34:56:00:f1:62',
'is_local': True,
'light_state': None,
'local_url': 'http://192.168.0.123/678460a0d47e5618699fb31169e2b47d',
'monitoring': None,
'motion_detection': True,
'sd_status': 4,
'supported_features': <CameraEntityFeature: 3>,
'vpn_url': 'https://prodvpn-eu-2.netatmo.net/restricted/10.255.123.45/609e27de5699fb18147ab47d06846631/MTRPn_BeWCav5RBq4U1OMDruTW4dkQ0NuMwNDAw11g,,',
}),
'context': <ANY>,
'entity_id': 'camera.hall',
'last_changed': <ANY>,
'last_updated': <ANY>,
'state': 'streaming',
})
# ---
# name: test_entity[camera.netatmo_doorbell-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'camera',
'entity_category': None,
'entity_id': 'camera.netatmo_doorbell',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': None,
'platform': 'netatmo',
'previous_unique_id': None,
'supported_features': <CameraEntityFeature: 1>,
'translation_key': None,
'unique_id': '12:34:56:10:f1:66-DeviceType.NDB',
'unit_of_measurement': None,
})
# ---
# name: test_entity[camera.netatmo_doorbell-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'access_token': '1caab5c3b3',
'alim_status': 2,
'attribution': 'Data provided by Netatmo',
'brand': 'Netatmo',
'entity_picture': '/api/camera_proxy/camera.netatmo_doorbell?token=1caab5c3b3',
'friendly_name': 'Netatmo-Doorbell',
'id': '12:34:56:10:f1:66',
'is_local': None,
'light_state': None,
'local_url': None,
'monitoring': None,
'sd_status': 4,
'supported_features': <CameraEntityFeature: 1>,
'vpn_url': 'https://prodvpn-eu-6.netatmo.net/10.20.30.40/1111111111111/2222222222222,,',
}),
'context': <ANY>,
'entity_id': 'camera.netatmo_doorbell',
'last_changed': <ANY>,
'last_updated': <ANY>,
'state': 'idle',
})
# ---

View File

@ -0,0 +1,385 @@
# serializer version: 1
# name: test_entity[climate.bureau-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'hvac_modes': list([
<HVACMode.AUTO: 'auto'>,
<HVACMode.HEAT: 'heat'>,
]),
'max_temp': 30,
'min_temp': 7,
'preset_modes': list([
'away',
'boost',
'Frost Guard',
'Schedule',
]),
'target_temp_step': 0.5,
}),
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'climate',
'entity_category': None,
'entity_id': 'climate.bureau',
'has_entity_name': False,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Bureau',
'platform': 'netatmo',
'previous_unique_id': None,
'supported_features': <ClimateEntityFeature: 17>,
'translation_key': None,
'unique_id': '222452125-DeviceType.OTM',
'unit_of_measurement': None,
})
# ---
# name: test_entity[climate.bureau-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'attribution': 'Data provided by Netatmo',
'friendly_name': 'Bureau',
'hvac_modes': list([
<HVACMode.AUTO: 'auto'>,
<HVACMode.HEAT: 'heat'>,
]),
'max_temp': 30,
'min_temp': 7,
'preset_modes': list([
'away',
'boost',
'Frost Guard',
'Schedule',
]),
'supported_features': <ClimateEntityFeature: 17>,
'target_temp_step': 0.5,
}),
'context': <ANY>,
'entity_id': 'climate.bureau',
'last_changed': <ANY>,
'last_updated': <ANY>,
'state': 'unavailable',
})
# ---
# name: test_entity[climate.cocina-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'hvac_modes': list([
<HVACMode.AUTO: 'auto'>,
<HVACMode.HEAT: 'heat'>,
]),
'max_temp': 30,
'min_temp': 7,
'preset_modes': list([
'away',
'boost',
'Frost Guard',
'Schedule',
]),
'target_temp_step': 0.5,
}),
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'climate',
'entity_category': None,
'entity_id': 'climate.cocina',
'has_entity_name': False,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Cocina',
'platform': 'netatmo',
'previous_unique_id': None,
'supported_features': <ClimateEntityFeature: 17>,
'translation_key': None,
'unique_id': '2940411577-DeviceType.NRV',
'unit_of_measurement': None,
})
# ---
# name: test_entity[climate.cocina-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'attribution': 'Data provided by Netatmo',
'current_temperature': 27,
'friendly_name': 'Cocina',
'heating_power_request': 0,
'hvac_action': <HVACAction.IDLE: 'idle'>,
'hvac_modes': list([
<HVACMode.AUTO: 'auto'>,
<HVACMode.HEAT: 'heat'>,
]),
'max_temp': 30,
'min_temp': 7,
'preset_mode': 'Frost Guard',
'preset_modes': list([
'away',
'boost',
'Frost Guard',
'Schedule',
]),
'selected_schedule': 'Default',
'supported_features': <ClimateEntityFeature: 17>,
'target_temp_step': 0.5,
'temperature': 7,
}),
'context': <ANY>,
'entity_id': 'climate.cocina',
'last_changed': <ANY>,
'last_updated': <ANY>,
'state': 'auto',
})
# ---
# name: test_entity[climate.corridor-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'hvac_modes': list([
<HVACMode.AUTO: 'auto'>,
<HVACMode.HEAT: 'heat'>,
]),
'max_temp': 30,
'min_temp': 7,
'preset_modes': list([
'away',
'boost',
'Frost Guard',
'Schedule',
]),
'target_temp_step': 0.5,
}),
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'climate',
'entity_category': None,
'entity_id': 'climate.corridor',
'has_entity_name': False,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Corridor',
'platform': 'netatmo',
'previous_unique_id': None,
'supported_features': <ClimateEntityFeature: 17>,
'translation_key': None,
'unique_id': '1002003001-DeviceType.BNS',
'unit_of_measurement': None,
})
# ---
# name: test_entity[climate.corridor-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'attribution': 'Data provided by Netatmo',
'current_temperature': 22,
'friendly_name': 'Corridor',
'hvac_action': <HVACAction.HEATING: 'heating'>,
'hvac_modes': list([
<HVACMode.AUTO: 'auto'>,
<HVACMode.HEAT: 'heat'>,
]),
'max_temp': 30,
'min_temp': 7,
'preset_mode': 'Schedule',
'preset_modes': list([
'away',
'boost',
'Frost Guard',
'Schedule',
]),
'selected_schedule': 'Default',
'supported_features': <ClimateEntityFeature: 17>,
'target_temp_step': 0.5,
'temperature': 22,
}),
'context': <ANY>,
'entity_id': 'climate.corridor',
'last_changed': <ANY>,
'last_updated': <ANY>,
'state': 'auto',
})
# ---
# name: test_entity[climate.entrada-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'hvac_modes': list([
<HVACMode.AUTO: 'auto'>,
<HVACMode.HEAT: 'heat'>,
]),
'max_temp': 30,
'min_temp': 7,
'preset_modes': list([
'away',
'boost',
'Frost Guard',
'Schedule',
]),
'target_temp_step': 0.5,
}),
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'climate',
'entity_category': None,
'entity_id': 'climate.entrada',
'has_entity_name': False,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Entrada',
'platform': 'netatmo',
'previous_unique_id': None,
'supported_features': <ClimateEntityFeature: 17>,
'translation_key': None,
'unique_id': '2833524037-DeviceType.NRV',
'unit_of_measurement': None,
})
# ---
# name: test_entity[climate.entrada-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'attribution': 'Data provided by Netatmo',
'current_temperature': 24.5,
'friendly_name': 'Entrada',
'heating_power_request': 0,
'hvac_action': <HVACAction.IDLE: 'idle'>,
'hvac_modes': list([
<HVACMode.AUTO: 'auto'>,
<HVACMode.HEAT: 'heat'>,
]),
'max_temp': 30,
'min_temp': 7,
'preset_mode': 'Frost Guard',
'preset_modes': list([
'away',
'boost',
'Frost Guard',
'Schedule',
]),
'selected_schedule': 'Default',
'supported_features': <ClimateEntityFeature: 17>,
'target_temp_step': 0.5,
'temperature': 7,
}),
'context': <ANY>,
'entity_id': 'climate.entrada',
'last_changed': <ANY>,
'last_updated': <ANY>,
'state': 'auto',
})
# ---
# name: test_entity[climate.livingroom-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'hvac_modes': list([
<HVACMode.AUTO: 'auto'>,
<HVACMode.HEAT: 'heat'>,
<HVACMode.OFF: 'off'>,
]),
'max_temp': 30,
'min_temp': 7,
'preset_modes': list([
'away',
'boost',
'Frost Guard',
'Schedule',
]),
'target_temp_step': 0.5,
}),
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'climate',
'entity_category': None,
'entity_id': 'climate.livingroom',
'has_entity_name': False,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Livingroom',
'platform': 'netatmo',
'previous_unique_id': None,
'supported_features': <ClimateEntityFeature: 17>,
'translation_key': None,
'unique_id': '2746182631-DeviceType.NATherm1',
'unit_of_measurement': None,
})
# ---
# name: test_entity[climate.livingroom-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'attribution': 'Data provided by Netatmo',
'current_temperature': 19.8,
'friendly_name': 'Livingroom',
'hvac_action': <HVACAction.IDLE: 'idle'>,
'hvac_modes': list([
<HVACMode.AUTO: 'auto'>,
<HVACMode.HEAT: 'heat'>,
<HVACMode.OFF: 'off'>,
]),
'max_temp': 30,
'min_temp': 7,
'preset_mode': 'away',
'preset_modes': list([
'away',
'boost',
'Frost Guard',
'Schedule',
]),
'selected_schedule': 'Default',
'supported_features': <ClimateEntityFeature: 17>,
'target_temp_step': 0.5,
'temperature': 12,
}),
'context': <ANY>,
'entity_id': 'climate.livingroom',
'last_changed': <ANY>,
'last_updated': <ANY>,
'state': 'auto',
})
# ---

View File

@ -0,0 +1,48 @@
# serializer version: 1
# name: test_entity[cover.entrance_blinds-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'cover',
'entity_category': None,
'entity_id': 'cover.entrance_blinds',
'has_entity_name': False,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'name': None,
'options': dict({
}),
'original_device_class': <CoverDeviceClass.SHUTTER: 'shutter'>,
'original_icon': None,
'original_name': 'Entrance Blinds',
'platform': 'netatmo',
'previous_unique_id': None,
'supported_features': <CoverEntityFeature: 15>,
'translation_key': None,
'unique_id': '0009999992-DeviceType.NBR',
'unit_of_measurement': None,
})
# ---
# name: test_entity[cover.entrance_blinds-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'attribution': 'Data provided by Netatmo',
'current_position': 0,
'device_class': 'shutter',
'friendly_name': 'Entrance Blinds',
'supported_features': <CoverEntityFeature: 15>,
}),
'context': <ANY>,
'entity_id': 'cover.entrance_blinds',
'last_changed': <ANY>,
'last_updated': <ANY>,
'state': 'closed',
})
# ---

View File

@ -0,0 +1,158 @@
# serializer version: 1
# name: test_entity[light.bathroom_light-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'supported_color_modes': list([
]),
}),
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'light',
'entity_category': None,
'entity_id': 'light.bathroom_light',
'has_entity_name': False,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Bathroom light',
'platform': 'netatmo',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': None,
'unique_id': '12:34:56:00:01:01:01:a1-light',
'unit_of_measurement': None,
})
# ---
# name: test_entity[light.bathroom_light-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'attribution': 'Data provided by Netatmo',
'color_mode': None,
'friendly_name': 'Bathroom light',
'supported_color_modes': list([
]),
'supported_features': <LightEntityFeature: 0>,
}),
'context': <ANY>,
'entity_id': 'light.bathroom_light',
'last_changed': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_entity[light.front-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'supported_color_modes': list([
<ColorMode.ONOFF: 'onoff'>,
]),
}),
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'light',
'entity_category': None,
'entity_id': 'light.front',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': None,
'platform': 'netatmo',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': None,
'unique_id': '12:34:56:10:b9:0e-light',
'unit_of_measurement': None,
})
# ---
# name: test_entity[light.front-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'attribution': 'Data provided by Netatmo',
'friendly_name': 'Front',
'supported_color_modes': list([
<ColorMode.ONOFF: 'onoff'>,
]),
'supported_features': <LightEntityFeature: 0>,
}),
'context': <ANY>,
'entity_id': 'light.front',
'last_changed': <ANY>,
'last_updated': <ANY>,
'state': 'unavailable',
})
# ---
# name: test_entity[light.unknown_00_11_22_33_00_11_45_fe-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'supported_color_modes': list([
<ColorMode.BRIGHTNESS: 'brightness'>,
]),
}),
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'light',
'entity_category': None,
'entity_id': 'light.unknown_00_11_22_33_00_11_45_fe',
'has_entity_name': False,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Unknown 00:11:22:33:00:11:45:fe',
'platform': 'netatmo',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': None,
'unique_id': '00:11:22:33:00:11:45:fe-light',
'unit_of_measurement': None,
})
# ---
# name: test_entity[light.unknown_00_11_22_33_00_11_45_fe-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'attribution': 'Data provided by Netatmo',
'brightness': None,
'color_mode': None,
'friendly_name': 'Unknown 00:11:22:33:00:11:45:fe',
'supported_color_modes': list([
<ColorMode.BRIGHTNESS: 'brightness'>,
]),
'supported_features': <LightEntityFeature: 0>,
}),
'context': <ANY>,
'entity_id': 'light.unknown_00_11_22_33_00_11_45_fe',
'last_changed': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---

View File

@ -0,0 +1,54 @@
# serializer version: 1
# name: test_entity[select.myhome-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'options': list([
'Default',
'Winter',
]),
}),
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'select',
'entity_category': None,
'entity_id': 'select.myhome',
'has_entity_name': False,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'MYHOME',
'platform': 'netatmo',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': None,
'unique_id': '91763b24c43d3e344f424e8b-schedule-select',
'unit_of_measurement': None,
})
# ---
# name: test_entity[select.myhome-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'attribution': 'Data provided by Netatmo',
'friendly_name': 'MYHOME',
'options': list([
'Default',
'Winter',
]),
}),
'context': <ANY>,
'entity_id': 'select.myhome',
'last_changed': <ANY>,
'last_updated': <ANY>,
'state': 'Default',
})
# ---

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,45 @@
# serializer version: 1
# name: test_entity[switch.prise-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'switch',
'entity_category': None,
'entity_id': 'switch.prise',
'has_entity_name': False,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Prise',
'platform': 'netatmo',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': None,
'unique_id': '12:34:56:80:00:12:ac:f2-DeviceType.NLP',
'unit_of_measurement': None,
})
# ---
# name: test_entity[switch.prise-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'attribution': 'Data provided by Netatmo',
'friendly_name': 'Prise',
}),
'context': <ANY>,
'entity_id': 'switch.prise',
'last_changed': <ANY>,
'last_updated': <ANY>,
'state': 'on',
})
# ---

View File

@ -5,6 +5,7 @@ from unittest.mock import AsyncMock, patch
import pyatmo
import pytest
from syrupy import SnapshotAssertion
from homeassistant.components import camera
from homeassistant.components.camera import STATE_STREAMING
@ -17,13 +18,37 @@ from homeassistant.components.netatmo.const import (
from homeassistant.const import CONF_WEBHOOK_ID, Platform
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
import homeassistant.helpers.entity_registry as er
from homeassistant.util import dt as dt_util
from .common import fake_post_request, selected_platforms, simulate_webhook
from .common import (
fake_post_request,
selected_platforms,
simulate_webhook,
snapshot_platform_entities,
)
from tests.common import MockConfigEntry, async_capture_events, async_fire_time_changed
async def test_entity(
hass: HomeAssistant,
config_entry: MockConfigEntry,
netatmo_auth: AsyncMock,
snapshot: SnapshotAssertion,
entity_registry: er.EntityRegistry,
) -> None:
"""Test entities."""
with patch("random.SystemRandom.getrandbits", return_value=123123123123):
await snapshot_platform_entities(
hass,
config_entry,
Platform.CAMERA,
entity_registry,
snapshot,
)
async def test_setup_component_with_webhook(
hass: HomeAssistant, config_entry: MockConfigEntry, netatmo_auth: AsyncMock
) -> None:

View File

@ -3,6 +3,7 @@ from datetime import timedelta
from unittest.mock import AsyncMock, patch
import pytest
from syrupy import SnapshotAssertion
from voluptuous.error import MultipleInvalid
from homeassistant.components.climate import (
@ -39,13 +40,31 @@ from homeassistant.const import (
)
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ServiceValidationError
import homeassistant.helpers.entity_registry as er
from homeassistant.util import dt as dt_util
from .common import selected_platforms, simulate_webhook
from .common import selected_platforms, simulate_webhook, snapshot_platform_entities
from tests.common import MockConfigEntry
async def test_entity(
hass: HomeAssistant,
config_entry: MockConfigEntry,
netatmo_auth: AsyncMock,
snapshot: SnapshotAssertion,
entity_registry: er.EntityRegistry,
) -> None:
"""Test entities."""
await snapshot_platform_entities(
hass,
config_entry,
Platform.CLIMATE,
entity_registry,
snapshot,
)
async def test_webhook_event_handling_thermostats(
hass: HomeAssistant, config_entry: MockConfigEntry, netatmo_auth: AsyncMock
) -> None:

View File

@ -1,6 +1,8 @@
"""The tests for Netatmo cover."""
from unittest.mock import AsyncMock, patch
from syrupy import SnapshotAssertion
from homeassistant.components.cover import (
ATTR_POSITION,
DOMAIN as COVER_DOMAIN,
@ -11,12 +13,30 @@ from homeassistant.components.cover import (
)
from homeassistant.const import ATTR_ENTITY_ID, Platform
from homeassistant.core import HomeAssistant
import homeassistant.helpers.entity_registry as er
from .common import selected_platforms
from .common import selected_platforms, snapshot_platform_entities
from tests.common import MockConfigEntry
async def test_entity(
hass: HomeAssistant,
config_entry: MockConfigEntry,
netatmo_auth: AsyncMock,
snapshot: SnapshotAssertion,
entity_registry: er.EntityRegistry,
) -> None:
"""Test entities."""
await snapshot_platform_entities(
hass,
config_entry,
Platform.COVER,
entity_registry,
snapshot,
)
async def test_cover_setup_and_services(
hass: HomeAssistant, config_entry: MockConfigEntry, netatmo_auth: AsyncMock
) -> None:

View File

@ -1,21 +1,46 @@
"""The tests for Netatmo light."""
from unittest.mock import AsyncMock, patch
from syrupy import SnapshotAssertion
from homeassistant.components.light import (
DOMAIN as LIGHT_DOMAIN,
SERVICE_TURN_OFF,
SERVICE_TURN_ON,
)
from homeassistant.components.netatmo import DOMAIN
from homeassistant.const import ATTR_ENTITY_ID, CONF_WEBHOOK_ID
from homeassistant.const import ATTR_ENTITY_ID, CONF_WEBHOOK_ID, Platform
from homeassistant.core import HomeAssistant
import homeassistant.helpers.entity_registry as er
from .common import FAKE_WEBHOOK_ACTIVATION, selected_platforms, simulate_webhook
from .common import (
FAKE_WEBHOOK_ACTIVATION,
selected_platforms,
simulate_webhook,
snapshot_platform_entities,
)
from tests.common import MockConfigEntry
from tests.test_util.aiohttp import AiohttpClientMockResponse
async def test_entity(
hass: HomeAssistant,
config_entry: MockConfigEntry,
netatmo_auth: AsyncMock,
snapshot: SnapshotAssertion,
entity_registry: er.EntityRegistry,
) -> None:
"""Test entities."""
await snapshot_platform_entities(
hass,
config_entry,
Platform.LIGHT,
entity_registry,
snapshot,
)
async def test_camera_light_setup_and_services(
hass: HomeAssistant, config_entry: MockConfigEntry, netatmo_auth: AsyncMock
) -> None:

View File

@ -2,20 +2,44 @@
from unittest.mock import AsyncMock, patch
import pytest
from syrupy import SnapshotAssertion
from homeassistant.components.select import (
ATTR_OPTION,
ATTR_OPTIONS,
DOMAIN as SELECT_DOMAIN,
)
from homeassistant.const import ATTR_ENTITY_ID, CONF_WEBHOOK_ID, SERVICE_SELECT_OPTION
from homeassistant.const import (
ATTR_ENTITY_ID,
CONF_WEBHOOK_ID,
SERVICE_SELECT_OPTION,
Platform,
)
from homeassistant.core import HomeAssistant
import homeassistant.helpers.entity_registry as er
from .common import selected_platforms, simulate_webhook
from .common import selected_platforms, simulate_webhook, snapshot_platform_entities
from tests.common import MockConfigEntry
async def test_entity(
hass: HomeAssistant,
config_entry: MockConfigEntry,
netatmo_auth: AsyncMock,
snapshot: SnapshotAssertion,
entity_registry: er.EntityRegistry,
) -> None:
"""Test entities."""
await snapshot_platform_entities(
hass,
config_entry,
Platform.SELECT,
entity_registry,
snapshot,
)
async def test_select_schedule_thermostats(
hass: HomeAssistant,
config_entry: MockConfigEntry,

View File

@ -2,17 +2,35 @@
from unittest.mock import AsyncMock
import pytest
from syrupy import SnapshotAssertion
from homeassistant.components.netatmo import sensor
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from .common import selected_platforms
from .common import selected_platforms, snapshot_platform_entities
from tests.common import MockConfigEntry
async def test_entity(
hass: HomeAssistant,
config_entry: MockConfigEntry,
netatmo_auth: AsyncMock,
snapshot: SnapshotAssertion,
entity_registry: er.EntityRegistry,
) -> None:
"""Test entities."""
await snapshot_platform_entities(
hass,
config_entry,
Platform.SENSOR,
entity_registry,
snapshot,
)
async def test_indoor_sensor(
hass: HomeAssistant, config_entry: MockConfigEntry, netatmo_auth: AsyncMock
) -> None:

View File

@ -1,6 +1,8 @@
"""The tests for Netatmo switch."""
from unittest.mock import AsyncMock, patch
from syrupy import SnapshotAssertion
from homeassistant.components.switch import (
DOMAIN as SWITCH_DOMAIN,
SERVICE_TURN_OFF,
@ -8,12 +10,30 @@ from homeassistant.components.switch import (
)
from homeassistant.const import ATTR_ENTITY_ID, Platform
from homeassistant.core import HomeAssistant
import homeassistant.helpers.entity_registry as er
from .common import selected_platforms
from .common import selected_platforms, snapshot_platform_entities
from tests.common import MockConfigEntry
async def test_entity(
hass: HomeAssistant,
config_entry: MockConfigEntry,
netatmo_auth: AsyncMock,
snapshot: SnapshotAssertion,
entity_registry: er.EntityRegistry,
) -> None:
"""Test entities."""
await snapshot_platform_entities(
hass,
config_entry,
Platform.SWITCH,
entity_registry,
snapshot,
)
async def test_switch_setup_and_services(
hass: HomeAssistant, config_entry: MockConfigEntry, netatmo_auth: AsyncMock
) -> None: