Improve tests in WLED (#157799)

Co-authored-by: mik-laj <12058428+mik-laj@users.noreply.github.com>
This commit is contained in:
Kamil Breguła
2025-12-29 16:26:49 +01:00
committed by GitHub
parent e1599dc53a
commit bdb456e568
17 changed files with 4581 additions and 836 deletions
@@ -6,10 +6,7 @@ rules:
appropriate-polling: done
brands: done
common-modules: done
config-flow-test-coverage:
status: todo
comment: |
test_connection_error and test_unsupported_version_error should end in CREATE_ENTRY
config-flow-test-coverage: done
config-flow: done
dependency-transparency: done
docs-actions:
@@ -38,13 +35,7 @@ rules:
status: exempt
comment: |
This integration does not require authentication.
test-coverage:
status: todo
comment: |
The test_setting_unique_id test is redundant.
The test_websocket_already_connected test can use the freezer.
The snapshot tests should be used more widely.
We should use pytest.mark.freeze_time instead of mock.
test-coverage: done
# Gold
devices: done
diagnostics: done
@@ -1,54 +1,5 @@
# serializer version: 1
# name: test_button_restart
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'restart',
'friendly_name': 'WLED RGB Light Restart',
}),
'context': <ANY>,
'entity_id': 'button.wled_rgb_light_restart',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unknown',
})
# ---
# name: test_button_restart.1
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'button',
'entity_category': <EntityCategory.CONFIG: 'config'>,
'entity_id': 'button.wled_rgb_light_restart',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <ButtonDeviceClass.RESTART: 'restart'>,
'original_icon': None,
'original_name': 'Restart',
'platform': 'wled',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': None,
'unique_id': 'aabbccddeeff_restart',
'unit_of_measurement': None,
})
# ---
# name: test_button_restart.2
# name: test_device_snapshot
DeviceRegistryEntrySnapshot({
'area_id': None,
'config_entries': <ANY>,
@@ -83,3 +34,52 @@
'via_device_id': None,
})
# ---
# name: test_snapshots[button.wled_rgb_light_restart-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'button',
'entity_category': <EntityCategory.CONFIG: 'config'>,
'entity_id': 'button.wled_rgb_light_restart',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <ButtonDeviceClass.RESTART: 'restart'>,
'original_icon': None,
'original_name': 'Restart',
'platform': 'wled',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': None,
'unique_id': 'aabbccddeeff_restart',
'unit_of_measurement': None,
})
# ---
# name: test_snapshots[button.wled_rgb_light_restart-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'restart',
'friendly_name': 'WLED RGB Light Restart',
}),
'context': <ANY>,
'entity_id': 'button.wled_rgb_light_restart',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unknown',
})
# ---
File diff suppressed because it is too large Load Diff
@@ -183,3 +183,231 @@
'via_device_id': None,
})
# ---
# name: test_snapshots[number.wled_rgb_light_intensity-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'max': 255,
'min': 0,
'mode': <NumberMode.AUTO: 'auto'>,
'step': 1,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'number',
'entity_category': <EntityCategory.CONFIG: 'config'>,
'entity_id': 'number.wled_rgb_light_intensity',
'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': 'Intensity',
'platform': 'wled',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'intensity',
'unique_id': 'aabbccddeeff_intensity_0',
'unit_of_measurement': None,
})
# ---
# name: test_snapshots[number.wled_rgb_light_intensity-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'WLED RGB Light Intensity',
'max': 255,
'min': 0,
'mode': <NumberMode.AUTO: 'auto'>,
'step': 1,
}),
'context': <ANY>,
'entity_id': 'number.wled_rgb_light_intensity',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '128',
})
# ---
# name: test_snapshots[number.wled_rgb_light_segment_1_intensity-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'max': 255,
'min': 0,
'mode': <NumberMode.AUTO: 'auto'>,
'step': 1,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'number',
'entity_category': <EntityCategory.CONFIG: 'config'>,
'entity_id': 'number.wled_rgb_light_segment_1_intensity',
'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': 'Segment 1 intensity',
'platform': 'wled',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'segment_intensity',
'unique_id': 'aabbccddeeff_intensity_1',
'unit_of_measurement': None,
})
# ---
# name: test_snapshots[number.wled_rgb_light_segment_1_intensity-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'WLED RGB Light Segment 1 intensity',
'max': 255,
'min': 0,
'mode': <NumberMode.AUTO: 'auto'>,
'step': 1,
}),
'context': <ANY>,
'entity_id': 'number.wled_rgb_light_segment_1_intensity',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '64',
})
# ---
# name: test_snapshots[number.wled_rgb_light_segment_1_speed-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'max': 255,
'min': 0,
'mode': <NumberMode.AUTO: 'auto'>,
'step': 1,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'number',
'entity_category': <EntityCategory.CONFIG: 'config'>,
'entity_id': 'number.wled_rgb_light_segment_1_speed',
'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': 'Segment 1 speed',
'platform': 'wled',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'segment_speed',
'unique_id': 'aabbccddeeff_speed_1',
'unit_of_measurement': None,
})
# ---
# name: test_snapshots[number.wled_rgb_light_segment_1_speed-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'WLED RGB Light Segment 1 speed',
'max': 255,
'min': 0,
'mode': <NumberMode.AUTO: 'auto'>,
'step': 1,
}),
'context': <ANY>,
'entity_id': 'number.wled_rgb_light_segment_1_speed',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '16',
})
# ---
# name: test_snapshots[number.wled_rgb_light_speed-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'max': 255,
'min': 0,
'mode': <NumberMode.AUTO: 'auto'>,
'step': 1,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'number',
'entity_category': <EntityCategory.CONFIG: 'config'>,
'entity_id': 'number.wled_rgb_light_speed',
'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': 'Speed',
'platform': 'wled',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'speed',
'unique_id': 'aabbccddeeff_speed_0',
'unit_of_measurement': None,
})
# ---
# name: test_snapshots[number.wled_rgb_light_speed-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'WLED RGB Light Speed',
'max': 255,
'min': 0,
'mode': <NumberMode.AUTO: 'auto'>,
'step': 1,
}),
'context': <ANY>,
'entity_id': 'number.wled_rgb_light_speed',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '32',
})
# ---
+321 -274
View File
@@ -1,32 +1,82 @@
# serializer version: 1
# name: test_color_palette_state[rgb-select.wled_rgb_light_live_override-2-live-called_with1]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'WLED RGB Light Live override',
'options': list([
'0',
'1',
'2',
]),
}),
'context': <ANY>,
'entity_id': 'select.wled_rgb_light_live_override',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '0',
})
# ---
# name: test_color_palette_state[rgb-select.wled_rgb_light_live_override-2-live-called_with1].1
# name: test_snapshots[select.wled_rgb_light_color_palette-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'options': list([
'0',
'1',
'2',
'* Color 1',
'* Color Gradient',
'* Colors 1&2',
'* Colors Only',
'* Random Cycle',
'Analogous',
'April Night',
'Aqua Flash',
'Atlantica',
'Aurora',
'Aurora 2',
'Autumn',
'Beach',
'Beech',
'Blink Red',
'Breeze',
'C9',
'C9 2',
'C9 New',
'Candy',
'Candy2',
'Cloud',
'Cyane',
'Default',
'Departure',
'Drywet',
'Fairy Reaf',
'Fire',
'Forest',
'Grintage',
'Hult',
'Hult 64',
'Icefire',
'Jul',
'Landscape',
'Lava',
'Light Pink',
'Lite Light',
'Magenta',
'Magred',
'Ocean',
'Orange & Teal',
'Orangery',
'Party',
'Pastel',
'Pink Candy',
'Rainbow',
'Rainbow Bands',
'Red & Blue',
'Red Flash',
'Red Reaf',
'Red Shift',
'Red Tide',
'Retro Clown',
'Rewhi',
'Rivendell',
'Sakura',
'Semi Blue',
'Sherbet',
'Splash',
'Sunset',
'Sunset 2',
'Temperature',
'Tertiary',
'Tiamat',
'Toxy Reaf',
'Vintage',
'Yelblu',
'Yelblu Hot',
'Yellowout',
'Yelmag',
]),
}),
'config_entry_id': <ANY>,
@@ -36,7 +86,7 @@
'disabled_by': None,
'domain': 'select',
'entity_category': <EntityCategory.CONFIG: 'config'>,
'entity_id': 'select.wled_rgb_light_live_override',
'entity_id': 'select.wled_rgb_light_color_palette',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
@@ -48,55 +98,20 @@
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Live override',
'original_name': 'Color palette',
'platform': 'wled',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'live_override',
'unique_id': 'aabbccddeeff_live_override',
'translation_key': 'color_palette',
'unique_id': 'aabbccddeeff_palette_0',
'unit_of_measurement': None,
})
# ---
# name: test_color_palette_state[rgb-select.wled_rgb_light_live_override-2-live-called_with1].2
DeviceRegistryEntrySnapshot({
'area_id': None,
'config_entries': <ANY>,
'config_entries_subentries': <ANY>,
'configuration_url': 'http://127.0.0.1',
'connections': set({
tuple(
'mac',
'aa:bb:cc:dd:ee:ff',
),
}),
'disabled_by': None,
'entry_type': None,
'hw_version': 'esp32',
'id': <ANY>,
'identifiers': set({
tuple(
'wled',
'aabbccddeeff',
),
}),
'labels': set({
}),
'manufacturer': 'WLED',
'model': 'FOSS',
'model_id': None,
'name': 'WLED RGB Light',
'name_by_user': None,
'primary_config_entry': <ANY>,
'serial_number': None,
'sw_version': '0.14.4',
'via_device_id': None,
})
# ---
# name: test_color_palette_state[rgb-select.wled_rgb_light_segment_1_color_palette-Icefire-segment-called_with0]
# name: test_snapshots[select.wled_rgb_light_color_palette-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'WLED RGB Light Segment 1 color palette',
'friendly_name': 'WLED RGB Light Color palette',
'options': list([
'* Color 1',
'* Color Gradient',
@@ -172,14 +187,179 @@
]),
}),
'context': <ANY>,
'entity_id': 'select.wled_rgb_light_segment_1_color_palette',
'entity_id': 'select.wled_rgb_light_color_palette',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '* Random Cycle',
'state': 'Default',
})
# ---
# name: test_color_palette_state[rgb-select.wled_rgb_light_segment_1_color_palette-Icefire-segment-called_with0].1
# name: test_snapshots[select.wled_rgb_light_live_override-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'options': list([
'0',
'1',
'2',
]),
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'select',
'entity_category': <EntityCategory.CONFIG: 'config'>,
'entity_id': 'select.wled_rgb_light_live_override',
'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': 'Live override',
'platform': 'wled',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'live_override',
'unique_id': 'aabbccddeeff_live_override',
'unit_of_measurement': None,
})
# ---
# name: test_snapshots[select.wled_rgb_light_live_override-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'WLED RGB Light Live override',
'options': list([
'0',
'1',
'2',
]),
}),
'context': <ANY>,
'entity_id': 'select.wled_rgb_light_live_override',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '0',
})
# ---
# name: test_snapshots[select.wled_rgb_light_playlist-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'options': list([
]),
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'select',
'entity_category': None,
'entity_id': 'select.wled_rgb_light_playlist',
'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': 'Playlist',
'platform': 'wled',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'playlist',
'unique_id': 'aabbccddeeff_playlist',
'unit_of_measurement': None,
})
# ---
# name: test_snapshots[select.wled_rgb_light_playlist-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'WLED RGB Light Playlist',
'options': list([
]),
}),
'context': <ANY>,
'entity_id': 'select.wled_rgb_light_playlist',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unavailable',
})
# ---
# name: test_snapshots[select.wled_rgb_light_preset-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'options': list([
]),
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'select',
'entity_category': None,
'entity_id': 'select.wled_rgb_light_preset',
'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': 'Preset',
'platform': 'wled',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'preset',
'unique_id': 'aabbccddeeff_preset',
'unit_of_measurement': None,
})
# ---
# name: test_snapshots[select.wled_rgb_light_preset-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'WLED RGB Light Preset',
'options': list([
]),
}),
'context': <ANY>,
'entity_id': 'select.wled_rgb_light_preset',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unavailable',
})
# ---
# name: test_snapshots[select.wled_rgb_light_segment_1_color_palette-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
@@ -288,222 +468,89 @@
'unit_of_measurement': None,
})
# ---
# name: test_color_palette_state[rgb-select.wled_rgb_light_segment_1_color_palette-Icefire-segment-called_with0].2
DeviceRegistryEntrySnapshot({
'area_id': None,
'config_entries': <ANY>,
'config_entries_subentries': <ANY>,
'configuration_url': 'http://127.0.0.1',
'connections': set({
tuple(
'mac',
'aa:bb:cc:dd:ee:ff',
),
}),
'disabled_by': None,
'entry_type': None,
'hw_version': 'esp32',
'id': <ANY>,
'identifiers': set({
tuple(
'wled',
'aabbccddeeff',
),
}),
'labels': set({
}),
'manufacturer': 'WLED',
'model': 'FOSS',
'model_id': None,
'name': 'WLED RGB Light',
'name_by_user': None,
'primary_config_entry': <ANY>,
'serial_number': None,
'sw_version': '0.14.4',
'via_device_id': None,
})
# ---
# name: test_color_palette_state[rgbw-select.wled_rgbw_light_playlist-Playlist 2-playlist-called_with2]
# name: test_snapshots[select.wled_rgb_light_segment_1_color_palette-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'WLED RGBW Light Playlist',
'friendly_name': 'WLED RGB Light Segment 1 color palette',
'options': list([
'Playlist 1',
'Playlist 2',
'* Color 1',
'* Color Gradient',
'* Colors 1&2',
'* Colors Only',
'* Random Cycle',
'Analogous',
'April Night',
'Aqua Flash',
'Atlantica',
'Aurora',
'Aurora 2',
'Autumn',
'Beach',
'Beech',
'Blink Red',
'Breeze',
'C9',
'C9 2',
'C9 New',
'Candy',
'Candy2',
'Cloud',
'Cyane',
'Default',
'Departure',
'Drywet',
'Fairy Reaf',
'Fire',
'Forest',
'Grintage',
'Hult',
'Hult 64',
'Icefire',
'Jul',
'Landscape',
'Lava',
'Light Pink',
'Lite Light',
'Magenta',
'Magred',
'Ocean',
'Orange & Teal',
'Orangery',
'Party',
'Pastel',
'Pink Candy',
'Rainbow',
'Rainbow Bands',
'Red & Blue',
'Red Flash',
'Red Reaf',
'Red Shift',
'Red Tide',
'Retro Clown',
'Rewhi',
'Rivendell',
'Sakura',
'Semi Blue',
'Sherbet',
'Splash',
'Sunset',
'Sunset 2',
'Temperature',
'Tertiary',
'Tiamat',
'Toxy Reaf',
'Vintage',
'Yelblu',
'Yelblu Hot',
'Yellowout',
'Yelmag',
]),
}),
'context': <ANY>,
'entity_id': 'select.wled_rgbw_light_playlist',
'entity_id': 'select.wled_rgb_light_segment_1_color_palette',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unknown',
})
# ---
# name: test_color_palette_state[rgbw-select.wled_rgbw_light_playlist-Playlist 2-playlist-called_with2].1
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'options': list([
'Playlist 1',
'Playlist 2',
]),
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'select',
'entity_category': None,
'entity_id': 'select.wled_rgbw_light_playlist',
'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': 'Playlist',
'platform': 'wled',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'playlist',
'unique_id': 'aabbccddeeff_playlist',
'unit_of_measurement': None,
})
# ---
# name: test_color_palette_state[rgbw-select.wled_rgbw_light_playlist-Playlist 2-playlist-called_with2].2
DeviceRegistryEntrySnapshot({
'area_id': None,
'config_entries': <ANY>,
'config_entries_subentries': <ANY>,
'configuration_url': 'http://127.0.0.1',
'connections': set({
tuple(
'mac',
'aa:bb:cc:dd:ee:ff',
),
}),
'disabled_by': None,
'entry_type': None,
'hw_version': 'esp32',
'id': <ANY>,
'identifiers': set({
tuple(
'wled',
'aabbccddeeff',
),
}),
'labels': set({
}),
'manufacturer': 'WLED',
'model': 'FOSS',
'model_id': None,
'name': 'WLED RGBW Light',
'name_by_user': None,
'primary_config_entry': <ANY>,
'serial_number': None,
'sw_version': '0.99.0b1',
'via_device_id': None,
})
# ---
# name: test_color_palette_state[rgbw-select.wled_rgbw_light_preset-Preset 2-preset-called_with3]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'WLED RGBW Light Preset',
'options': list([
'Preset 1',
'Preset 2',
]),
}),
'context': <ANY>,
'entity_id': 'select.wled_rgbw_light_preset',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unknown',
})
# ---
# name: test_color_palette_state[rgbw-select.wled_rgbw_light_preset-Preset 2-preset-called_with3].1
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'options': list([
'Preset 1',
'Preset 2',
]),
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'select',
'entity_category': None,
'entity_id': 'select.wled_rgbw_light_preset',
'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': 'Preset',
'platform': 'wled',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'preset',
'unique_id': 'aabbccddeeff_preset',
'unit_of_measurement': None,
})
# ---
# name: test_color_palette_state[rgbw-select.wled_rgbw_light_preset-Preset 2-preset-called_with3].2
DeviceRegistryEntrySnapshot({
'area_id': None,
'config_entries': <ANY>,
'config_entries_subentries': <ANY>,
'configuration_url': 'http://127.0.0.1',
'connections': set({
tuple(
'mac',
'aa:bb:cc:dd:ee:ff',
),
}),
'disabled_by': None,
'entry_type': None,
'hw_version': 'esp32',
'id': <ANY>,
'identifiers': set({
tuple(
'wled',
'aabbccddeeff',
),
}),
'labels': set({
}),
'manufacturer': 'WLED',
'model': 'FOSS',
'model_id': None,
'name': 'WLED RGBW Light',
'name_by_user': None,
'primary_config_entry': <ANY>,
'serial_number': None,
'sw_version': '0.99.0b1',
'via_device_id': None,
'state': '* Random Cycle',
})
# ---
@@ -0,0 +1,512 @@
# serializer version: 1
# name: test_snapshots[sensor.wled_rgb_light_estimated_current-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'sensor.wled_rgb_light_estimated_current',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
'sensor': dict({
'suggested_display_precision': 0,
}),
}),
'original_device_class': <SensorDeviceClass.CURRENT: 'current'>,
'original_icon': None,
'original_name': 'Estimated current',
'platform': 'wled',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'estimated_current',
'unique_id': 'aabbccddeeff_estimated_current',
'unit_of_measurement': <UnitOfElectricCurrent.MILLIAMPERE: 'mA'>,
})
# ---
# name: test_snapshots[sensor.wled_rgb_light_estimated_current-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'current',
'friendly_name': 'WLED RGB Light Estimated current',
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
'unit_of_measurement': <UnitOfElectricCurrent.MILLIAMPERE: 'mA'>,
}),
'context': <ANY>,
'entity_id': 'sensor.wled_rgb_light_estimated_current',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '515',
})
# ---
# name: test_snapshots[sensor.wled_rgb_light_free_memory-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'sensor.wled_rgb_light_free_memory',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
'sensor': dict({
'suggested_display_precision': 0,
}),
}),
'original_device_class': <SensorDeviceClass.DATA_SIZE: 'data_size'>,
'original_icon': None,
'original_name': 'Free memory',
'platform': 'wled',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'free_heap',
'unique_id': 'aabbccddeeff_free_heap',
'unit_of_measurement': <UnitOfInformation.BYTES: 'B'>,
})
# ---
# name: test_snapshots[sensor.wled_rgb_light_free_memory-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'data_size',
'friendly_name': 'WLED RGB Light Free memory',
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
'unit_of_measurement': <UnitOfInformation.BYTES: 'B'>,
}),
'context': <ANY>,
'entity_id': 'sensor.wled_rgb_light_free_memory',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '198384',
})
# ---
# name: test_snapshots[sensor.wled_rgb_light_ip-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'sensor.wled_rgb_light_ip',
'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': 'IP',
'platform': 'wled',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'ip',
'unique_id': 'aabbccddeeff_ip',
'unit_of_measurement': None,
})
# ---
# name: test_snapshots[sensor.wled_rgb_light_ip-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'WLED RGB Light IP',
}),
'context': <ANY>,
'entity_id': 'sensor.wled_rgb_light_ip',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '127.0.0.1',
})
# ---
# name: test_snapshots[sensor.wled_rgb_light_led_count-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'sensor.wled_rgb_light_led_count',
'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': 'LED count',
'platform': 'wled',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'info_leds_count',
'unique_id': 'aabbccddeeff_info_leds_count',
'unit_of_measurement': None,
})
# ---
# name: test_snapshots[sensor.wled_rgb_light_led_count-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'WLED RGB Light LED count',
}),
'context': <ANY>,
'entity_id': 'sensor.wled_rgb_light_led_count',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '30',
})
# ---
# name: test_snapshots[sensor.wled_rgb_light_max_current-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'sensor.wled_rgb_light_max_current',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
'sensor': dict({
'suggested_display_precision': 0,
}),
}),
'original_device_class': <SensorDeviceClass.CURRENT: 'current'>,
'original_icon': None,
'original_name': 'Max current',
'platform': 'wled',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'info_leds_max_power',
'unique_id': 'aabbccddeeff_info_leds_max_power',
'unit_of_measurement': <UnitOfElectricCurrent.MILLIAMPERE: 'mA'>,
})
# ---
# name: test_snapshots[sensor.wled_rgb_light_max_current-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'current',
'friendly_name': 'WLED RGB Light Max current',
'unit_of_measurement': <UnitOfElectricCurrent.MILLIAMPERE: 'mA'>,
}),
'context': <ANY>,
'entity_id': 'sensor.wled_rgb_light_max_current',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '850',
})
# ---
# name: test_snapshots[sensor.wled_rgb_light_uptime-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'sensor.wled_rgb_light_uptime',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <SensorDeviceClass.TIMESTAMP: 'timestamp'>,
'original_icon': None,
'original_name': 'Uptime',
'platform': 'wled',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'uptime',
'unique_id': 'aabbccddeeff_uptime',
'unit_of_measurement': None,
})
# ---
# name: test_snapshots[sensor.wled_rgb_light_uptime-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'timestamp',
'friendly_name': 'WLED RGB Light Uptime',
}),
'context': <ANY>,
'entity_id': 'sensor.wled_rgb_light_uptime',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '2021-11-04T16:20:53+00:00',
})
# ---
# name: test_snapshots[sensor.wled_rgb_light_wi_fi_bssid-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'sensor.wled_rgb_light_wi_fi_bssid',
'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': 'Wi-Fi BSSID',
'platform': 'wled',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'wifi_bssid',
'unique_id': 'aabbccddeeff_wifi_bssid',
'unit_of_measurement': None,
})
# ---
# name: test_snapshots[sensor.wled_rgb_light_wi_fi_bssid-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'WLED RGB Light Wi-Fi BSSID',
}),
'context': <ANY>,
'entity_id': 'sensor.wled_rgb_light_wi_fi_bssid',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'AA:AA:AA:AA:AA:BB',
})
# ---
# name: test_snapshots[sensor.wled_rgb_light_wi_fi_channel-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'sensor.wled_rgb_light_wi_fi_channel',
'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': 'Wi-Fi channel',
'platform': 'wled',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'wifi_channel',
'unique_id': 'aabbccddeeff_wifi_channel',
'unit_of_measurement': None,
})
# ---
# name: test_snapshots[sensor.wled_rgb_light_wi_fi_channel-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'WLED RGB Light Wi-Fi channel',
}),
'context': <ANY>,
'entity_id': 'sensor.wled_rgb_light_wi_fi_channel',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '11',
})
# ---
# name: test_snapshots[sensor.wled_rgb_light_wi_fi_rssi-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'sensor.wled_rgb_light_wi_fi_rssi',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <SensorDeviceClass.SIGNAL_STRENGTH: 'signal_strength'>,
'original_icon': None,
'original_name': 'Wi-Fi RSSI',
'platform': 'wled',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'wifi_rssi',
'unique_id': 'aabbccddeeff_wifi_rssi',
'unit_of_measurement': 'dBm',
})
# ---
# name: test_snapshots[sensor.wled_rgb_light_wi_fi_rssi-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'signal_strength',
'friendly_name': 'WLED RGB Light Wi-Fi RSSI',
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
'unit_of_measurement': 'dBm',
}),
'context': <ANY>,
'entity_id': 'sensor.wled_rgb_light_wi_fi_rssi',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '-43',
})
# ---
# name: test_snapshots[sensor.wled_rgb_light_wi_fi_signal-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'sensor.wled_rgb_light_wi_fi_signal',
'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': 'Wi-Fi signal',
'platform': 'wled',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'wifi_signal',
'unique_id': 'aabbccddeeff_wifi_signal',
'unit_of_measurement': '%',
})
# ---
# name: test_snapshots[sensor.wled_rgb_light_wi_fi_signal-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'WLED RGB Light Wi-Fi signal',
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
'unit_of_measurement': '%',
}),
'context': <ANY>,
'entity_id': 'sensor.wled_rgb_light_wi_fi_signal',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '100',
})
# ---
+266 -162
View File
@@ -1,20 +1,5 @@
# serializer version: 1
# name: test_switch_state[switch.wled_rgb_light_nightlight-nightlight-called_with_on0-called_with_off0]
StateSnapshot({
'attributes': ReadOnlyDict({
'duration': 60,
'friendly_name': 'WLED RGB Light Nightlight',
'target_brightness': 0,
}),
'context': <ANY>,
'entity_id': 'switch.wled_rgb_light_nightlight',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_switch_state[switch.wled_rgb_light_nightlight-nightlight-called_with_on0-called_with_off0].1
# name: test_snapshots[rgb][switch.wled_rgb_light_nightlight-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
@@ -49,55 +34,22 @@
'unit_of_measurement': None,
})
# ---
# name: test_switch_state[switch.wled_rgb_light_nightlight-nightlight-called_with_on0-called_with_off0].2
DeviceRegistryEntrySnapshot({
'area_id': None,
'config_entries': <ANY>,
'config_entries_subentries': <ANY>,
'configuration_url': 'http://127.0.0.1',
'connections': set({
tuple(
'mac',
'aa:bb:cc:dd:ee:ff',
),
}),
'disabled_by': None,
'entry_type': None,
'hw_version': 'esp32',
'id': <ANY>,
'identifiers': set({
tuple(
'wled',
'aabbccddeeff',
),
}),
'labels': set({
}),
'manufacturer': 'WLED',
'model': 'FOSS',
'model_id': None,
'name': 'WLED RGB Light',
'name_by_user': None,
'primary_config_entry': <ANY>,
'serial_number': None,
'sw_version': '0.14.4',
'via_device_id': None,
})
# ---
# name: test_switch_state[switch.wled_rgb_light_reverse-segment-called_with_on1-called_with_off1]
# name: test_snapshots[rgb][switch.wled_rgb_light_nightlight-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'WLED RGB Light Reverse',
'duration': 60,
'friendly_name': 'WLED RGB Light Nightlight',
'target_brightness': 0,
}),
'context': <ANY>,
'entity_id': 'switch.wled_rgb_light_reverse',
'entity_id': 'switch.wled_rgb_light_nightlight',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_switch_state[switch.wled_rgb_light_reverse-segment-called_with_on1-called_with_off1].1
# name: test_snapshots[rgb][switch.wled_rgb_light_reverse-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
@@ -132,56 +84,68 @@
'unit_of_measurement': None,
})
# ---
# name: test_switch_state[switch.wled_rgb_light_reverse-segment-called_with_on1-called_with_off1].2
DeviceRegistryEntrySnapshot({
'area_id': None,
'config_entries': <ANY>,
'config_entries_subentries': <ANY>,
'configuration_url': 'http://127.0.0.1',
'connections': set({
tuple(
'mac',
'aa:bb:cc:dd:ee:ff',
),
}),
'disabled_by': None,
'entry_type': None,
'hw_version': 'esp32',
'id': <ANY>,
'identifiers': set({
tuple(
'wled',
'aabbccddeeff',
),
}),
'labels': set({
}),
'manufacturer': 'WLED',
'model': 'FOSS',
'model_id': None,
'name': 'WLED RGB Light',
'name_by_user': None,
'primary_config_entry': <ANY>,
'serial_number': None,
'sw_version': '0.14.4',
'via_device_id': None,
})
# ---
# name: test_switch_state[switch.wled_rgb_light_sync_receive-sync-called_with_on2-called_with_off2]
# name: test_snapshots[rgb][switch.wled_rgb_light_reverse-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'WLED RGB Light Sync receive',
'udp_port': 21324,
'friendly_name': 'WLED RGB Light Reverse',
}),
'context': <ANY>,
'entity_id': 'switch.wled_rgb_light_sync_receive',
'entity_id': 'switch.wled_rgb_light_reverse',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_snapshots[rgb][switch.wled_rgb_light_segment_1_reverse-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'switch',
'entity_category': <EntityCategory.CONFIG: 'config'>,
'entity_id': 'switch.wled_rgb_light_segment_1_reverse',
'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': 'Segment 1 reverse',
'platform': 'wled',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'segment_reverse',
'unique_id': 'aabbccddeeff_reverse_1',
'unit_of_measurement': None,
})
# ---
# name: test_snapshots[rgb][switch.wled_rgb_light_segment_1_reverse-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'WLED RGB Light Segment 1 reverse',
}),
'context': <ANY>,
'entity_id': 'switch.wled_rgb_light_segment_1_reverse',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'on',
})
# ---
# name: test_switch_state[switch.wled_rgb_light_sync_receive-sync-called_with_on2-called_with_off2].1
# name: test_snapshots[rgb][switch.wled_rgb_light_sync_receive-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
@@ -216,56 +180,21 @@
'unit_of_measurement': None,
})
# ---
# name: test_switch_state[switch.wled_rgb_light_sync_receive-sync-called_with_on2-called_with_off2].2
DeviceRegistryEntrySnapshot({
'area_id': None,
'config_entries': <ANY>,
'config_entries_subentries': <ANY>,
'configuration_url': 'http://127.0.0.1',
'connections': set({
tuple(
'mac',
'aa:bb:cc:dd:ee:ff',
),
}),
'disabled_by': None,
'entry_type': None,
'hw_version': 'esp32',
'id': <ANY>,
'identifiers': set({
tuple(
'wled',
'aabbccddeeff',
),
}),
'labels': set({
}),
'manufacturer': 'WLED',
'model': 'FOSS',
'model_id': None,
'name': 'WLED RGB Light',
'name_by_user': None,
'primary_config_entry': <ANY>,
'serial_number': None,
'sw_version': '0.14.4',
'via_device_id': None,
})
# ---
# name: test_switch_state[switch.wled_rgb_light_sync_send-sync-called_with_on3-called_with_off3]
# name: test_snapshots[rgb][switch.wled_rgb_light_sync_receive-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'WLED RGB Light Sync send',
'friendly_name': 'WLED RGB Light Sync receive',
'udp_port': 21324,
}),
'context': <ANY>,
'entity_id': 'switch.wled_rgb_light_sync_send',
'entity_id': 'switch.wled_rgb_light_sync_receive',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
'state': 'on',
})
# ---
# name: test_switch_state[switch.wled_rgb_light_sync_send-sync-called_with_on3-called_with_off3].1
# name: test_snapshots[rgb][switch.wled_rgb_light_sync_send-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
@@ -300,38 +229,213 @@
'unit_of_measurement': None,
})
# ---
# name: test_switch_state[switch.wled_rgb_light_sync_send-sync-called_with_on3-called_with_off3].2
DeviceRegistryEntrySnapshot({
'area_id': None,
'config_entries': <ANY>,
'config_entries_subentries': <ANY>,
'configuration_url': 'http://127.0.0.1',
'connections': set({
tuple(
'mac',
'aa:bb:cc:dd:ee:ff',
),
# name: test_snapshots[rgb][switch.wled_rgb_light_sync_send-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'WLED RGB Light Sync send',
'udp_port': 21324,
}),
'context': <ANY>,
'entity_id': 'switch.wled_rgb_light_sync_send',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_snapshots[rgb_single_segment][switch.wled_rgb_light_nightlight-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'entry_type': None,
'hw_version': 'esp32',
'domain': 'switch',
'entity_category': <EntityCategory.CONFIG: 'config'>,
'entity_id': 'switch.wled_rgb_light_nightlight',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'identifiers': set({
tuple(
'wled',
'aabbccddeeff',
),
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Nightlight',
'platform': 'wled',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'nightlight',
'unique_id': 'aabbccddeeff_nightlight',
'unit_of_measurement': None,
})
# ---
# name: test_snapshots[rgb_single_segment][switch.wled_rgb_light_nightlight-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'duration': 60,
'friendly_name': 'WLED RGB Light Nightlight',
'target_brightness': 0,
}),
'context': <ANY>,
'entity_id': 'switch.wled_rgb_light_nightlight',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_snapshots[rgb_single_segment][switch.wled_rgb_light_reverse-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'switch',
'entity_category': <EntityCategory.CONFIG: 'config'>,
'entity_id': 'switch.wled_rgb_light_reverse',
'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': 'Reverse',
'platform': 'wled',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'reverse',
'unique_id': 'aabbccddeeff_reverse_0',
'unit_of_measurement': None,
})
# ---
# name: test_snapshots[rgb_single_segment][switch.wled_rgb_light_reverse-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'WLED RGB Light Reverse',
}),
'context': <ANY>,
'entity_id': 'switch.wled_rgb_light_reverse',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_snapshots[rgb_single_segment][switch.wled_rgb_light_sync_receive-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'switch',
'entity_category': <EntityCategory.CONFIG: 'config'>,
'entity_id': 'switch.wled_rgb_light_sync_receive',
'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': 'Sync receive',
'platform': 'wled',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'sync_receive',
'unique_id': 'aabbccddeeff_sync_receive',
'unit_of_measurement': None,
})
# ---
# name: test_snapshots[rgb_single_segment][switch.wled_rgb_light_sync_receive-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'WLED RGB Light Sync receive',
'udp_port': 21324,
}),
'context': <ANY>,
'entity_id': 'switch.wled_rgb_light_sync_receive',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'on',
})
# ---
# name: test_snapshots[rgb_single_segment][switch.wled_rgb_light_sync_send-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'switch',
'entity_category': <EntityCategory.CONFIG: 'config'>,
'entity_id': 'switch.wled_rgb_light_sync_send',
'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': 'Sync send',
'platform': 'wled',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'sync_send',
'unique_id': 'aabbccddeeff_sync_send',
'unit_of_measurement': None,
})
# ---
# name: test_snapshots[rgb_single_segment][switch.wled_rgb_light_sync_send-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'WLED RGB Light Sync send',
'udp_port': 21324,
}),
'manufacturer': 'WLED',
'model': 'FOSS',
'model_id': None,
'name': 'WLED RGB Light',
'name_by_user': None,
'primary_config_entry': <ANY>,
'serial_number': None,
'sw_version': '0.14.4',
'via_device_id': None,
'context': <ANY>,
'entity_id': 'switch.wled_rgb_light_sync_send',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
@@ -0,0 +1,140 @@
# serializer version: 1
# name: test_no_update_available[rgb_websocket]
StateSnapshot({
'attributes': ReadOnlyDict({
'auto_update': False,
'device_class': 'firmware',
'display_precision': 0,
'entity_picture': 'https://brands.home-assistant.io/_/wled/icon.png',
'friendly_name': 'WLED WebSocket Firmware',
'in_progress': False,
'installed_version': '0.99.0',
'latest_version': '0.99.0',
'release_summary': None,
'release_url': 'https://github.com/wled/WLED/releases/tag/v0.99.0',
'skipped_version': None,
'supported_features': <UpdateEntityFeature: 3>,
'title': 'WLED',
'update_percentage': None,
}),
'context': <ANY>,
'entity_id': 'update.wled_websocket_firmware',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_update_available.2
StateSnapshot({
'attributes': ReadOnlyDict({
'auto_update': False,
'device_class': 'firmware',
'display_precision': 0,
'entity_picture': 'https://brands.home-assistant.io/_/wled/icon.png',
'friendly_name': 'WLED RGB Light Firmware',
'in_progress': False,
'installed_version': '0.14.4',
'latest_version': '0.99.0',
'release_summary': None,
'release_url': 'https://github.com/wled/WLED/releases/tag/v0.99.0',
'skipped_version': None,
'supported_features': <UpdateEntityFeature: 3>,
'title': 'WLED',
'update_percentage': None,
}),
'context': <ANY>,
'entity_id': 'update.wled_rgb_light_firmware',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'on',
})
# ---
# name: test_update_available[update.wled_rgb_light_firmware-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'update',
'entity_category': <EntityCategory.CONFIG: 'config'>,
'entity_id': 'update.wled_rgb_light_firmware',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <UpdateDeviceClass.FIRMWARE: 'firmware'>,
'original_icon': None,
'original_name': 'Firmware',
'platform': 'wled',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': <UpdateEntityFeature: 3>,
'translation_key': None,
'unique_id': 'aabbccddeeff',
'unit_of_measurement': None,
})
# ---
# name: test_update_available[update.wled_rgb_light_firmware-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'auto_update': False,
'device_class': 'firmware',
'display_precision': 0,
'entity_picture': 'https://brands.home-assistant.io/_/wled/icon.png',
'friendly_name': 'WLED RGB Light Firmware',
'in_progress': False,
'installed_version': '0.14.4',
'latest_version': '0.99.0',
'release_summary': None,
'release_url': 'https://github.com/wled/WLED/releases/tag/v0.99.0',
'skipped_version': None,
'supported_features': <UpdateEntityFeature: 3>,
'title': 'WLED',
'update_percentage': None,
}),
'context': <ANY>,
'entity_id': 'update.wled_rgb_light_firmware',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'on',
})
# ---
# name: test_update_information_available
StateSnapshot({
'attributes': ReadOnlyDict({
'auto_update': False,
'device_class': 'firmware',
'display_precision': 0,
'entity_picture': 'https://brands.home-assistant.io/_/wled/icon.png',
'friendly_name': 'WLED RGB Light Firmware',
'in_progress': False,
'installed_version': '0.14.4',
'latest_version': None,
'release_summary': None,
'release_url': None,
'skipped_version': None,
'supported_features': <UpdateEntityFeature: 3>,
'title': 'WLED',
'update_percentage': None,
}),
'context': <ANY>,
'entity_id': 'update.wled_rgb_light_firmware',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unknown',
})
# ---
+65 -29
View File
@@ -1,6 +1,7 @@
"""Tests for the WLED button platform."""
from unittest.mock import MagicMock
from collections.abc import Generator
from unittest.mock import MagicMock, patch
import pytest
from syrupy.assertion import SnapshotAssertion
@@ -8,17 +9,58 @@ from wled import WLEDConnectionError, WLEDError
from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN, SERVICE_PRESS
from homeassistant.components.wled.const import DOMAIN
from homeassistant.const import ATTR_ENTITY_ID, STATE_UNAVAILABLE, STATE_UNKNOWN
from homeassistant.const import (
ATTR_ENTITY_ID,
STATE_UNAVAILABLE,
STATE_UNKNOWN,
Platform,
)
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import device_registry as dr, entity_registry as er
from tests.common import MockConfigEntry, snapshot_platform
pytestmark = [
pytest.mark.usefixtures("init_integration"),
pytest.mark.freeze_time("2021-11-04 17:36:59+01:00"),
]
@pytest.fixture(autouse=True)
def override_platforms() -> Generator[None]:
"""Override PLATFORMS."""
with patch("homeassistant.components.wled.PLATFORMS", [Platform.BUTTON]):
yield
@pytest.mark.usefixtures("init_integration")
async def test_snapshots(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
snapshot: SnapshotAssertion,
mock_config_entry: MockConfigEntry,
) -> None:
"""Test snapshot of the platform."""
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
@pytest.mark.usefixtures("init_integration")
async def test_device_snapshot(
hass: HomeAssistant,
device_registry: dr.DeviceRegistry,
entity_registry: er.EntityRegistry,
snapshot: SnapshotAssertion,
mock_config_entry: MockConfigEntry,
) -> None:
"""Test device snapshot."""
assert (entity_entry := entity_registry.async_get("button.wled_rgb_light_restart"))
assert entity_entry.device_id
assert (device_entry := device_registry.async_get(entity_entry.device_id))
assert device_entry == snapshot
async def test_button_restart(
hass: HomeAssistant,
device_registry: dr.DeviceRegistry,
@@ -26,16 +68,8 @@ async def test_button_restart(
mock_wled: MagicMock,
snapshot: SnapshotAssertion,
) -> None:
"""Test the creation and values of the WLED button."""
"""Test the behavior of the restart button."""
assert (state := hass.states.get("button.wled_rgb_light_restart"))
assert state == snapshot
assert (entity_entry := entity_registry.async_get(state.entity_id))
assert entity_entry == snapshot
assert entity_entry.device_id
assert (device_entry := device_registry.async_get(entity_entry.device_id))
assert device_entry == snapshot
assert state.state == STATE_UNKNOWN
await hass.services.async_call(
@@ -50,24 +84,26 @@ async def test_button_restart(
assert (state := hass.states.get("button.wled_rgb_light_restart"))
assert state.state == "2021-11-04T16:37:00+00:00"
# Test with WLED error
mock_wled.reset.side_effect = WLEDError
with pytest.raises(HomeAssistantError) as ex:
await hass.services.async_call(
BUTTON_DOMAIN,
SERVICE_PRESS,
{ATTR_ENTITY_ID: "button.wled_rgb_light_restart"},
blocking=True,
)
assert ex.value.translation_domain == DOMAIN
assert ex.value.translation_key == "invalid_response_wled_error"
# Ensure this didn't made the entity unavailable
assert (state := hass.states.get("button.wled_rgb_light_restart"))
assert state.state != STATE_UNAVAILABLE
@pytest.mark.parametrize(
("side_effect", "expected_state", "expected_translation_key"),
[
(WLEDError, "2021-11-04T16:37:00+00:00", "invalid_response_wled_error"),
(WLEDConnectionError, STATE_UNAVAILABLE, "connection_error"),
],
)
async def test_button_restart_errors(
hass: HomeAssistant,
device_registry: dr.DeviceRegistry,
entity_registry: er.EntityRegistry,
mock_wled: MagicMock,
side_effect: Exception,
expected_state: str,
expected_translation_key: str,
) -> None:
"""Test the error handling of the restart button."""
# Test with WLED connection error
mock_wled.reset.side_effect = WLEDConnectionError
mock_wled.reset.side_effect = side_effect
with pytest.raises(HomeAssistantError) as ex:
await hass.services.async_call(
BUTTON_DOMAIN,
@@ -77,8 +113,8 @@ async def test_button_restart(
)
assert ex.value.translation_domain == DOMAIN
assert ex.value.translation_key == "connection_error"
assert ex.value.translation_key == expected_translation_key
# Ensure this made the entity unavailable
assert (state := hass.states.get("button.wled_rgb_light_restart"))
assert state.state == STATE_UNAVAILABLE
assert state.state == expected_state
+19 -25
View File
@@ -15,6 +15,8 @@ from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
from tests.common import MockConfigEntry
CONFIG = {CONF_HOST: "10.10.0.10"}
@pytest.mark.usefixtures("mock_setup_entry", "mock_wled")
@pytest.mark.parametrize(
@@ -61,7 +63,7 @@ async def test_full_reconfigure_flow_success(
assert result.get("step_id") == "user"
assert result.get("type") is FlowResultType.FORM
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={CONF_HOST: "10.10.0.10"}
result["flow_id"], user_input=CONFIG
)
# Assert show text message and close flow
@@ -91,7 +93,7 @@ async def test_full_reconfigure_flow_unique_id_mismatch(
# Input new host value
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={CONF_HOST: "10.10.0.10"}
result["flow_id"], user_input=CONFIG
)
# Assert Show text message and close flow
@@ -117,7 +119,7 @@ async def test_full_reconfigure_flow_connection_error_and_success(
# Input new host value
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={CONF_HOST: "10.10.0.10"}
result["flow_id"], user_input=CONFIG
)
# Assert form with errors
@@ -129,7 +131,7 @@ async def test_full_reconfigure_flow_connection_error_and_success(
mock_wled.update.side_effect = None
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={CONF_HOST: "10.10.0.10"}
result["flow_id"], user_input=CONFIG
)
# Assert show text message and close flow
@@ -212,35 +214,27 @@ async def test_zeroconf_during_onboarding(
assert len(mock_onboarding.mock_calls) == 1
async def test_connection_error(hass: HomeAssistant, mock_wled: MagicMock) -> None:
"""Test we show user form on WLED connection error."""
mock_wled.update.side_effect = WLEDConnectionError
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_USER},
data={CONF_HOST: "example.com"},
)
assert result.get("type") is FlowResultType.FORM
assert result.get("step_id") == "user"
assert result.get("errors") == {"base": "cannot_connect"}
async def test_unsupported_version_error(
hass: HomeAssistant, mock_wled: MagicMock
@pytest.mark.parametrize(
("exception", "errors"),
[
(WLEDConnectionError, {"base": "cannot_connect"}),
(WLEDUnsupportedVersionError, {"base": "unsupported_version"}),
],
)
async def test_form_submission_errors(
hass: HomeAssistant, mock_wled: MagicMock, exception: Exception, errors: dict
) -> None:
"""Test we show user form on WLED unsupported version error."""
mock_wled.update.side_effect = WLEDUnsupportedVersionError
"""Test errors during form submission."""
mock_wled.update.side_effect = exception
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_USER},
data={CONF_HOST: "example.com"},
data=CONFIG,
)
assert result.get("type") is FlowResultType.FORM
assert result.get("step_id") == "user"
assert result.get("errors") == {"base": "unsupported_version"}
assert result.get("errors") == errors
async def test_zeroconf_connection_error(
+20 -7
View File
@@ -5,6 +5,7 @@ from collections.abc import Callable
from copy import deepcopy
from unittest.mock import MagicMock
from freezegun.api import FrozenDateTimeFactory
import pytest
from wled import (
Device as WLEDDevice,
@@ -23,7 +24,6 @@ from homeassistant.const import (
STATE_UNAVAILABLE,
)
from homeassistant.core import HomeAssistant
from homeassistant.util import dt as dt_util
from tests.common import MockConfigEntry, async_fire_time_changed
@@ -37,13 +37,18 @@ async def test_not_supporting_websocket(
@pytest.mark.parametrize("device_fixture", ["rgb_websocket"])
async def test_websocket_already_connected(
hass: HomeAssistant, init_integration: MockConfigEntry, mock_wled: MagicMock
hass: HomeAssistant,
init_integration: MockConfigEntry,
mock_wled: MagicMock,
freezer: FrozenDateTimeFactory,
) -> None:
"""Ensure no a second WebSocket connection is made, if already connected."""
assert mock_wled.connect.call_count == 1
mock_wled.connected = True
async_fire_time_changed(hass, dt_util.utcnow() + SCAN_INTERVAL)
freezer.tick(SCAN_INTERVAL)
async_fire_time_changed(hass)
await hass.async_block_till_done()
assert mock_wled.connect.call_count == 1
@@ -54,13 +59,15 @@ async def test_websocket_connect_error_no_listen(
hass: HomeAssistant,
init_integration: MockConfigEntry,
mock_wled: MagicMock,
freezer: FrozenDateTimeFactory,
) -> None:
"""Ensure we don't start listening if WebSocket connection failed."""
assert mock_wled.connect.call_count == 1
assert mock_wled.listen.call_count == 1
mock_wled.connect.side_effect = WLEDConnectionError
async_fire_time_changed(hass, dt_util.utcnow() + SCAN_INTERVAL)
freezer.tick(SCAN_INTERVAL)
async_fire_time_changed(hass)
await hass.async_block_till_done()
assert mock_wled.connect.call_count == 2
@@ -72,6 +79,7 @@ async def test_websocket(
hass: HomeAssistant,
init_integration: MockConfigEntry,
mock_wled: MagicMock,
freezer: FrozenDateTimeFactory,
) -> None:
"""Test WebSocket connection."""
state = hass.states.get("light.wled_websocket")
@@ -98,7 +106,8 @@ async def test_websocket(
hass.bus = mock_bus
# Next refresh it should connect
async_fire_time_changed(hass, dt_util.utcnow() + SCAN_INTERVAL)
freezer.tick(SCAN_INTERVAL)
async_fire_time_changed(hass)
callback = await connection_connected
# Connected to WebSocket, disconnect not called
@@ -145,6 +154,7 @@ async def test_websocket_error(
hass: HomeAssistant,
init_integration: MockConfigEntry,
mock_wled: MagicMock,
freezer: FrozenDateTimeFactory,
) -> None:
"""Test WebSocket connection erroring out, marking lights unavailable."""
state = hass.states.get("light.wled_websocket")
@@ -159,7 +169,8 @@ async def test_websocket_error(
await connection_finished
mock_wled.listen.side_effect = connect
async_fire_time_changed(hass, dt_util.utcnow() + SCAN_INTERVAL)
freezer.tick(SCAN_INTERVAL)
async_fire_time_changed(hass)
await connection_connected
# Resolve Future with an error.
@@ -177,6 +188,7 @@ async def test_websocket_disconnect_on_home_assistant_stop(
hass: HomeAssistant,
init_integration: MockConfigEntry,
mock_wled: MagicMock,
freezer: FrozenDateTimeFactory,
) -> None:
"""Ensure WebSocket is disconnected when Home Assistant stops."""
assert mock_wled.disconnect.call_count == 1
@@ -188,7 +200,8 @@ async def test_websocket_disconnect_on_home_assistant_stop(
await connection_finished
mock_wled.listen.side_effect = connect
async_fire_time_changed(hass, dt_util.utcnow() + SCAN_INTERVAL)
freezer.tick(SCAN_INTERVAL)
async_fire_time_changed(hass)
await connection_connected
assert mock_wled.disconnect.call_count == 1
+38 -59
View File
@@ -1,9 +1,11 @@
"""Tests for the WLED light platform."""
from unittest.mock import MagicMock
from collections.abc import Generator
from unittest.mock import MagicMock, patch
from freezegun.api import FrozenDateTimeFactory
import pytest
from syrupy.assertion import SnapshotAssertion
from wled import Device as WLEDDevice, WLEDConnectionError, WLEDError
from homeassistant.components.light import (
@@ -11,7 +13,6 @@ from homeassistant.components.light import (
ATTR_COLOR_MODE,
ATTR_COLOR_TEMP_KELVIN,
ATTR_EFFECT,
ATTR_HS_COLOR,
ATTR_MAX_COLOR_TEMP_KELVIN,
ATTR_MIN_COLOR_TEMP_KELVIN,
ATTR_RGB_COLOR,
@@ -28,12 +29,12 @@ from homeassistant.components.wled.const import (
)
from homeassistant.const import (
ATTR_ENTITY_ID,
ATTR_ICON,
SERVICE_TURN_OFF,
SERVICE_TURN_ON,
STATE_OFF,
STATE_ON,
STATE_UNAVAILABLE,
Platform,
)
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
@@ -43,44 +44,30 @@ from tests.common import (
MockConfigEntry,
async_fire_time_changed,
async_load_json_object_fixture,
snapshot_platform,
)
pytestmark = pytest.mark.usefixtures("init_integration")
async def test_rgb_light_state(
hass: HomeAssistant, entity_registry: er.EntityRegistry
@pytest.fixture(autouse=True)
def override_platforms() -> Generator[None]:
"""Override PLATFORMS."""
with patch("homeassistant.components.wled.PLATFORMS", [Platform.LIGHT]):
yield
@pytest.mark.parametrize(
"device_fixture", ["cct", "rgb_single_segment", "rgb", "rgb_websocket", "rgbw"]
)
async def test_snapshots(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
snapshot: SnapshotAssertion,
mock_config_entry: MockConfigEntry,
) -> None:
"""Test the creation and values of the WLED lights."""
# First segment of the strip
assert (state := hass.states.get("light.wled_rgb_light"))
assert state.attributes.get(ATTR_BRIGHTNESS) == 255
assert state.attributes.get(ATTR_EFFECT) == "Solid"
assert state.attributes.get(ATTR_HS_COLOR) == (218.906, 50.196)
assert state.attributes.get(ATTR_ICON) is None
assert state.state == STATE_ON
assert (entry := entity_registry.async_get("light.wled_rgb_light"))
assert entry.unique_id == "aabbccddeeff_0"
# Second segment of the strip
assert (state := hass.states.get("light.wled_rgb_light_segment_1"))
assert state.attributes.get(ATTR_BRIGHTNESS) == 255
assert state.attributes.get(ATTR_EFFECT) == "Wipe"
assert state.attributes.get(ATTR_HS_COLOR) == (40.0, 100.0)
assert state.attributes.get(ATTR_ICON) is None
assert state.state == STATE_ON
assert (entry := entity_registry.async_get("light.wled_rgb_light_segment_1"))
assert entry.unique_id == "aabbccddeeff_1"
# Test main control of the lightstrip
assert (state := hass.states.get("light.wled_rgb_light_main"))
assert state.attributes.get(ATTR_BRIGHTNESS) == 128
assert state.state == STATE_ON
assert (entry := entity_registry.async_get("light.wled_rgb_light_main"))
assert entry.unique_id == "aabbccddeeff"
"""Test snapshots of the platform."""
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
async def test_segment_change_state(
@@ -293,14 +280,24 @@ async def test_single_segment_behavior(
mock_wled.master.assert_called_with(on=True, transition=50, brightness=42)
async def test_light_error(
@pytest.mark.parametrize(
("side_effect", "expected_state", "expected_translation_key"),
[
(WLEDError, STATE_ON, "invalid_response_wled_error"),
(WLEDConnectionError, STATE_UNAVAILABLE, "connection_error"),
],
)
async def test_light_errors(
hass: HomeAssistant,
mock_wled: MagicMock,
side_effect: Exception,
expected_state: str,
expected_translation_key: str,
) -> None:
"""Test error handling of the WLED lights."""
mock_wled.segment.side_effect = WLEDError
mock_wled.segment.side_effect = side_effect
with pytest.raises(HomeAssistantError, match="Invalid response from WLED API"):
with pytest.raises(HomeAssistantError) as ex:
await hass.services.async_call(
LIGHT_DOMAIN,
SERVICE_TURN_OFF,
@@ -308,29 +305,11 @@ async def test_light_error(
blocking=True,
)
assert (state := hass.states.get("light.wled_rgb_light"))
assert state.state == STATE_ON
assert mock_wled.segment.call_count == 1
mock_wled.segment.assert_called_with(on=False, segment_id=0, transition=None)
async def test_light_connection_error(
hass: HomeAssistant,
mock_wled: MagicMock,
) -> None:
"""Test error handling of the WLED switches."""
mock_wled.segment.side_effect = WLEDConnectionError
with pytest.raises(HomeAssistantError, match="Error communicating with WLED API"):
await hass.services.async_call(
LIGHT_DOMAIN,
SERVICE_TURN_OFF,
{ATTR_ENTITY_ID: "light.wled_rgb_light"},
blocking=True,
)
assert ex.value.translation_domain == DOMAIN
assert ex.value.translation_key == expected_translation_key
assert (state := hass.states.get("light.wled_rgb_light"))
assert state.state == STATE_UNAVAILABLE
assert state.state == expected_state
assert mock_wled.segment.call_count == 1
mock_wled.segment.assert_called_with(on=False, segment_id=0, transition=None)
+26 -3
View File
@@ -1,6 +1,7 @@
"""Tests for the WLED number platform."""
from unittest.mock import MagicMock
from collections.abc import Generator
from unittest.mock import MagicMock, patch
from freezegun.api import FrozenDateTimeFactory
import pytest
@@ -13,16 +14,38 @@ from homeassistant.components.number import (
SERVICE_SET_VALUE,
)
from homeassistant.components.wled.const import DOMAIN, SCAN_INTERVAL
from homeassistant.const import ATTR_ENTITY_ID, STATE_UNAVAILABLE
from homeassistant.const import ATTR_ENTITY_ID, STATE_UNAVAILABLE, Platform
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import device_registry as dr, entity_registry as er
from tests.common import async_fire_time_changed, async_load_json_object_fixture
from tests.common import (
MockConfigEntry,
async_fire_time_changed,
async_load_json_object_fixture,
snapshot_platform,
)
pytestmark = pytest.mark.usefixtures("init_integration")
@pytest.fixture(autouse=True)
def override_platforms() -> Generator[None]:
"""Override PLATFORMS."""
with patch("homeassistant.components.wled.PLATFORMS", [Platform.NUMBER]):
yield
async def test_snapshots(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
snapshot: SnapshotAssertion,
mock_config_entry: MockConfigEntry,
) -> None:
"""Test snapshot of the platform."""
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
@pytest.mark.parametrize(
("entity_id", "value", "called_arg"),
[
+35 -18
View File
@@ -1,7 +1,8 @@
"""Tests for the WLED select platform."""
from collections.abc import Generator
import typing
from unittest.mock import MagicMock
from unittest.mock import MagicMock, patch
from freezegun.api import FrozenDateTimeFactory
import pytest
@@ -17,16 +18,43 @@ from wled import (
from homeassistant.components.select import ATTR_OPTION, DOMAIN as SELECT_DOMAIN
from homeassistant.components.wled.const import DOMAIN, SCAN_INTERVAL
from homeassistant.const import ATTR_ENTITY_ID, SERVICE_SELECT_OPTION, STATE_UNAVAILABLE
from homeassistant.const import (
ATTR_ENTITY_ID,
SERVICE_SELECT_OPTION,
STATE_UNAVAILABLE,
Platform,
)
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import device_registry as dr, entity_registry as er
from tests.common import async_fire_time_changed, async_load_json_object_fixture
from tests.common import (
MockConfigEntry,
async_fire_time_changed,
async_load_json_object_fixture,
snapshot_platform,
)
pytestmark = pytest.mark.usefixtures("init_integration")
@pytest.fixture(autouse=True)
def override_platforms() -> Generator[None]:
"""Override PLATFORMS."""
with patch("homeassistant.components.wled.PLATFORMS", [Platform.SELECT]):
yield
async def test_snapshots(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
snapshot: SnapshotAssertion,
mock_config_entry: MockConfigEntry,
) -> None:
"""Test snapshots of the platform."""
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
@pytest.mark.parametrize(
("device_fixture", "entity_id", "option", "method", "called_with"),
[
@@ -71,24 +99,13 @@ async def test_color_palette_state(
method: str,
called_with: dict[str, int | str],
) -> None:
"""Test the creation and values of the WLED selects."""
# First segment of the strip
assert (state := hass.states.get(entity_id))
assert state == snapshot
assert (entity_entry := entity_registry.async_get(state.entity_id))
assert entity_entry == snapshot
assert entity_entry.device_id
assert (device_entry := device_registry.async_get(entity_entry.device_id))
assert device_entry == snapshot
"""Test the behavior of the WLED selects."""
method_mock = getattr(mock_wled, method)
await hass.services.async_call(
SELECT_DOMAIN,
SERVICE_SELECT_OPTION,
{ATTR_ENTITY_ID: state.entity_id, ATTR_OPTION: option},
{ATTR_ENTITY_ID: entity_id, ATTR_OPTION: option},
blocking=True,
)
assert method_mock.call_count == 1
@@ -100,11 +117,11 @@ async def test_color_palette_state(
await hass.services.async_call(
SELECT_DOMAIN,
SERVICE_SELECT_OPTION,
{ATTR_ENTITY_ID: state.entity_id, ATTR_OPTION: option},
{ATTR_ENTITY_ID: entity_id, ATTR_OPTION: option},
blocking=True,
)
assert (state := hass.states.get(state.entity_id))
assert (state := hass.states.get(entity_id))
assert state.state != STATE_UNAVAILABLE
assert method_mock.call_count == 2
method_mock.assert_called_with(**called_with)
+19 -107
View File
@@ -1,126 +1,38 @@
"""Tests for the WLED sensor platform."""
from datetime import datetime
from collections.abc import Generator
from unittest.mock import MagicMock, patch
from freezegun.api import FrozenDateTimeFactory
import pytest
from syrupy.assertion import SnapshotAssertion
from homeassistant.components.sensor import SensorDeviceClass
from homeassistant.components.wled.const import SCAN_INTERVAL
from homeassistant.const import (
ATTR_DEVICE_CLASS,
ATTR_ICON,
ATTR_UNIT_OF_MEASUREMENT,
PERCENTAGE,
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
STATE_UNKNOWN,
EntityCategory,
UnitOfElectricCurrent,
UnitOfInformation,
)
from homeassistant.const import STATE_UNKNOWN, Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from homeassistant.util import dt as dt_util
from tests.common import MockConfigEntry, async_fire_time_changed
from tests.common import MockConfigEntry, async_fire_time_changed, snapshot_platform
@pytest.mark.usefixtures("entity_registry_enabled_by_default", "mock_wled")
async def test_sensors(
@pytest.fixture(autouse=True)
def override_platforms() -> Generator[None]:
"""Override PLATFORMS."""
with patch("homeassistant.components.wled.PLATFORMS", [Platform.SENSOR]):
yield
@pytest.mark.usefixtures("init_integration")
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
@pytest.mark.freeze_time("2021-11-04 17:36:59+01:00")
async def test_snapshots(
hass: HomeAssistant,
mock_config_entry: MockConfigEntry,
entity_registry: er.EntityRegistry,
snapshot: SnapshotAssertion,
mock_config_entry: MockConfigEntry,
) -> None:
"""Test the creation and values of the WLED sensors."""
mock_config_entry.add_to_hass(hass)
test_time = datetime(2019, 11, 11, 9, 10, 32, tzinfo=dt_util.UTC)
with patch("homeassistant.components.wled.sensor.utcnow", return_value=test_time):
await hass.config_entries.async_setup(mock_config_entry.entry_id)
await hass.async_block_till_done()
assert (state := hass.states.get("sensor.wled_rgb_light_estimated_current"))
assert (
state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
== UnitOfElectricCurrent.MILLIAMPERE
)
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.CURRENT
assert state.state == "515"
assert (
entry := entity_registry.async_get("sensor.wled_rgb_light_estimated_current")
)
assert entry.unique_id == "aabbccddeeff_estimated_current"
assert entry.entity_category is EntityCategory.DIAGNOSTIC
assert (state := hass.states.get("sensor.wled_rgb_light_uptime"))
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.TIMESTAMP
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) is None
assert state.state == "2019-11-11T08:54:26+00:00"
assert (entry := entity_registry.async_get("sensor.wled_rgb_light_uptime"))
assert entry.unique_id == "aabbccddeeff_uptime"
assert entry.entity_category is EntityCategory.DIAGNOSTIC
assert (state := hass.states.get("sensor.wled_rgb_light_free_memory"))
assert state.attributes.get(ATTR_ICON) is None
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfInformation.BYTES
assert state.state == "198384"
assert entry.entity_category is EntityCategory.DIAGNOSTIC
assert (entry := entity_registry.async_get("sensor.wled_rgb_light_free_memory"))
assert entry.unique_id == "aabbccddeeff_free_heap"
assert entry.entity_category is EntityCategory.DIAGNOSTIC
assert (state := hass.states.get("sensor.wled_rgb_light_wi_fi_signal"))
assert state.attributes.get(ATTR_ICON) is None
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
assert state.state == "100"
assert entry.entity_category is EntityCategory.DIAGNOSTIC
assert (entry := entity_registry.async_get("sensor.wled_rgb_light_wi_fi_signal"))
assert entry.unique_id == "aabbccddeeff_wifi_signal"
assert entry.entity_category is EntityCategory.DIAGNOSTIC
assert (state := hass.states.get("sensor.wled_rgb_light_wi_fi_rssi"))
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.SIGNAL_STRENGTH
assert (
state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
== SIGNAL_STRENGTH_DECIBELS_MILLIWATT
)
assert state.state == "-43"
assert (entry := entity_registry.async_get("sensor.wled_rgb_light_wi_fi_rssi"))
assert entry.unique_id == "aabbccddeeff_wifi_rssi"
assert entry.entity_category is EntityCategory.DIAGNOSTIC
assert (state := hass.states.get("sensor.wled_rgb_light_wi_fi_channel"))
assert state.attributes.get(ATTR_ICON) is None
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) is None
assert state.state == "11"
assert (entry := entity_registry.async_get("sensor.wled_rgb_light_wi_fi_channel"))
assert entry.unique_id == "aabbccddeeff_wifi_channel"
assert entry.entity_category is EntityCategory.DIAGNOSTIC
assert (state := hass.states.get("sensor.wled_rgb_light_wi_fi_bssid"))
assert state.attributes.get(ATTR_ICON) is None
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) is None
assert state.state == "AA:AA:AA:AA:AA:BB"
assert (entry := entity_registry.async_get("sensor.wled_rgb_light_wi_fi_bssid"))
assert entry.unique_id == "aabbccddeeff_wifi_bssid"
assert entry.entity_category is EntityCategory.DIAGNOSTIC
assert (state := hass.states.get("sensor.wled_rgb_light_ip"))
assert state.attributes.get(ATTR_ICON) is None
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) is None
assert state.state == "127.0.0.1"
assert (entry := entity_registry.async_get("sensor.wled_rgb_light_ip"))
assert entry.unique_id == "aabbccddeeff_ip"
assert entry.entity_category is EntityCategory.DIAGNOSTIC
"""Test snapshot of the platform."""
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
@pytest.mark.parametrize(
+32 -17
View File
@@ -1,6 +1,7 @@
"""Tests for the WLED switch platform."""
from unittest.mock import MagicMock
from collections.abc import Generator
from unittest.mock import MagicMock, patch
from freezegun.api import FrozenDateTimeFactory
import pytest
@@ -16,16 +17,40 @@ from homeassistant.const import (
STATE_OFF,
STATE_ON,
STATE_UNAVAILABLE,
Platform,
)
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import device_registry as dr, entity_registry as er
from tests.common import async_fire_time_changed, async_load_json_object_fixture
from tests.common import (
MockConfigEntry,
async_fire_time_changed,
async_load_json_object_fixture,
snapshot_platform,
)
pytestmark = pytest.mark.usefixtures("init_integration")
@pytest.fixture(autouse=True)
def override_platforms() -> Generator[None]:
"""Override PLATFORMS."""
with patch("homeassistant.components.wled.PLATFORMS", [Platform.SWITCH]):
yield
@pytest.mark.parametrize("device_fixture", ["rgb_single_segment", "rgb"])
async def test_snapshots(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
snapshot: SnapshotAssertion,
mock_config_entry: MockConfigEntry,
) -> None:
"""Test snapshot of the platform."""
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
@pytest.mark.parametrize(
("entity_id", "method", "called_with_on", "called_with_off"),
[
@@ -66,24 +91,14 @@ async def test_switch_state(
called_with_on: dict[str, bool | int],
called_with_off: dict[str, bool | int],
) -> None:
"""Test the creation and values of the WLED switches."""
assert (state := hass.states.get(entity_id))
assert state == snapshot
assert (entity_entry := entity_registry.async_get(state.entity_id))
assert entity_entry == snapshot
assert entity_entry.device_id
assert (device_entry := device_registry.async_get(entity_entry.device_id))
assert device_entry == snapshot
"""Test the behavior of the switch."""
# Test on/off services
method_mock = getattr(mock_wled, method)
await hass.services.async_call(
SWITCH_DOMAIN,
SERVICE_TURN_ON,
{ATTR_ENTITY_ID: state.entity_id},
{ATTR_ENTITY_ID: entity_id},
blocking=True,
)
@@ -93,7 +108,7 @@ async def test_switch_state(
await hass.services.async_call(
SWITCH_DOMAIN,
SERVICE_TURN_OFF,
{ATTR_ENTITY_ID: state.entity_id},
{ATTR_ENTITY_ID: entity_id},
blocking=True,
)
@@ -106,12 +121,12 @@ async def test_switch_state(
await hass.services.async_call(
SWITCH_DOMAIN,
SERVICE_TURN_ON,
{ATTR_ENTITY_ID: state.entity_id},
{ATTR_ENTITY_ID: entity_id},
blocking=True,
)
assert method_mock.call_count == 3
assert (state := hass.states.get(state.entity_id))
assert (state := hass.states.get(entity_id))
assert state.state != STATE_UNAVAILABLE
# Test connection error, leading to becoming unavailable
+30 -74
View File
@@ -1,71 +1,56 @@
"""Tests for the WLED update platform."""
from unittest.mock import MagicMock
from collections.abc import Generator
from unittest.mock import MagicMock, patch
from freezegun.api import FrozenDateTimeFactory
import pytest
from syrupy.assertion import SnapshotAssertion
from wled import Releases, WLEDError
from homeassistant.components.update import (
ATTR_INSTALLED_VERSION,
ATTR_LATEST_VERSION,
ATTR_RELEASE_SUMMARY,
ATTR_RELEASE_URL,
ATTR_TITLE,
DOMAIN as UPDATE_DOMAIN,
SERVICE_INSTALL,
UpdateDeviceClass,
UpdateEntityFeature,
)
from homeassistant.components.wled.const import RELEASES_SCAN_INTERVAL
from homeassistant.const import (
ATTR_DEVICE_CLASS,
ATTR_ENTITY_ID,
ATTR_ENTITY_PICTURE,
ATTR_ICON,
ATTR_SUPPORTED_FEATURES,
STATE_OFF,
STATE_ON,
STATE_UNAVAILABLE,
STATE_UNKNOWN,
EntityCategory,
Platform,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from tests.common import async_fire_time_changed
from tests.common import MockConfigEntry, async_fire_time_changed, snapshot_platform
pytestmark = pytest.mark.usefixtures("init_integration")
async def test_update_available(
hass: HomeAssistant, entity_registry: er.EntityRegistry
) -> None:
"""Test the firmware update available."""
assert (state := hass.states.get("update.wled_rgb_light_firmware"))
assert state.attributes.get(ATTR_DEVICE_CLASS) == UpdateDeviceClass.FIRMWARE
assert state.state == STATE_ON
assert (
state.attributes[ATTR_ENTITY_PICTURE]
== "https://brands.home-assistant.io/_/wled/icon.png"
)
assert state.attributes[ATTR_INSTALLED_VERSION] == "0.14.4"
assert state.attributes[ATTR_LATEST_VERSION] == "0.99.0"
assert state.attributes[ATTR_RELEASE_SUMMARY] is None
assert (
state.attributes[ATTR_RELEASE_URL]
== "https://github.com/wled/WLED/releases/tag/v0.99.0"
)
assert (
state.attributes[ATTR_SUPPORTED_FEATURES]
== UpdateEntityFeature.INSTALL | UpdateEntityFeature.SPECIFIC_VERSION
)
assert state.attributes[ATTR_TITLE] == "WLED"
assert ATTR_ICON not in state.attributes
@pytest.fixture(autouse=True)
def override_platforms() -> Generator[None]:
"""Override PLATFORMS."""
with patch("homeassistant.components.wled.PLATFORMS", [Platform.UPDATE]):
yield
assert (entry := entity_registry.async_get("update.wled_rgb_light_firmware"))
assert entry.unique_id == "aabbccddeeff"
assert entry.entity_category is EntityCategory.CONFIG
async def test_update_available(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
snapshot: SnapshotAssertion,
mock_config_entry: MockConfigEntry,
) -> None:
"""Test states of the update."""
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
assert (state := hass.states.get("update.wled_rgb_light_firmware"))
assert state.state == STATE_ON
assert snapshot == state
async def test_update_information_available(
@@ -73,6 +58,7 @@ async def test_update_information_available(
freezer: FrozenDateTimeFactory,
entity_registry: er.EntityRegistry,
mock_wled_releases: MagicMock,
snapshot: SnapshotAssertion,
) -> None:
"""Test having no update information available at all."""
mock_wled_releases.releases.return_value = Releases(
@@ -85,53 +71,23 @@ async def test_update_information_available(
await hass.async_block_till_done()
assert (state := hass.states.get("update.wled_rgb_light_firmware"))
assert state.attributes.get(ATTR_DEVICE_CLASS) == UpdateDeviceClass.FIRMWARE
assert state.state == STATE_UNKNOWN
assert state.attributes[ATTR_INSTALLED_VERSION] == "0.14.4"
assert state.attributes[ATTR_LATEST_VERSION] is None
assert state.attributes[ATTR_RELEASE_SUMMARY] is None
assert state.attributes[ATTR_RELEASE_URL] is None
assert (
state.attributes[ATTR_SUPPORTED_FEATURES]
== UpdateEntityFeature.INSTALL | UpdateEntityFeature.SPECIFIC_VERSION
)
assert state.attributes[ATTR_TITLE] == "WLED"
assert ATTR_ICON not in state.attributes
entry = entity_registry.async_get("update.wled_rgb_light_firmware")
assert entry
assert entry.unique_id == "aabbccddeeff"
assert entry.entity_category is EntityCategory.CONFIG
assert snapshot == state
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
@pytest.mark.parametrize("device_fixture", ["rgb_websocket"])
async def test_no_update_available(
hass: HomeAssistant, entity_registry: er.EntityRegistry
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
snapshot: SnapshotAssertion,
) -> None:
"""Test there is no update available."""
assert (state := hass.states.get("update.wled_websocket_firmware"))
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_DEVICE_CLASS) == UpdateDeviceClass.FIRMWARE
assert state.attributes[ATTR_INSTALLED_VERSION] == "0.99.0"
assert state.attributes[ATTR_LATEST_VERSION] == "0.99.0"
assert state.attributes[ATTR_RELEASE_SUMMARY] is None
assert (
state.attributes[ATTR_RELEASE_URL]
== "https://github.com/wled/WLED/releases/tag/v0.99.0"
)
assert (
state.attributes[ATTR_SUPPORTED_FEATURES]
== UpdateEntityFeature.INSTALL | UpdateEntityFeature.SPECIFIC_VERSION
)
assert state.attributes[ATTR_TITLE] == "WLED"
assert ATTR_ICON not in state.attributes
assert ATTR_ICON not in state.attributes
assert (entry := entity_registry.async_get("update.wled_websocket_firmware"))
assert entry.unique_id == "aabbccddeeff"
assert entry.entity_category is EntityCategory.CONFIG
assert snapshot == state
async def test_update_error(