Skip to content

Commit 4ef1779

Browse files
authored
Add snapshot test to Vivotek (home-assistant#157767)
1 parent 9373378 commit 4ef1779

File tree

3 files changed

+90
-0
lines changed

3 files changed

+90
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,12 @@
11
"""Tests for Vivotek camera component."""
2+
3+
from homeassistant.core import HomeAssistant
4+
5+
from tests.common import MockConfigEntry
6+
7+
8+
async def setup_integration(hass: HomeAssistant, config_entry: MockConfigEntry) -> None:
9+
"""Fixture for setting up the component."""
10+
config_entry.add_to_hass(hass)
11+
await hass.config_entries.async_setup(config_entry.entry_id)
12+
await hass.async_block_till_done()
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# serializer version: 1
2+
# name: test_all_entities[camera.vivotek_camera-entry]
3+
EntityRegistryEntrySnapshot({
4+
'aliases': set({
5+
}),
6+
'area_id': None,
7+
'capabilities': None,
8+
'config_entry_id': <ANY>,
9+
'config_subentry_id': <ANY>,
10+
'device_class': None,
11+
'device_id': <ANY>,
12+
'disabled_by': None,
13+
'domain': 'camera',
14+
'entity_category': None,
15+
'entity_id': 'camera.vivotek_camera',
16+
'has_entity_name': False,
17+
'hidden_by': None,
18+
'icon': None,
19+
'id': <ANY>,
20+
'labels': set({
21+
}),
22+
'name': None,
23+
'options': dict({
24+
}),
25+
'original_device_class': None,
26+
'original_icon': None,
27+
'original_name': 'Vivotek Camera',
28+
'platform': 'vivotek',
29+
'previous_unique_id': None,
30+
'suggested_object_id': None,
31+
'supported_features': <CameraEntityFeature: 2>,
32+
'translation_key': None,
33+
'unique_id': '11:22:33:44:55:66',
34+
'unit_of_measurement': None,
35+
})
36+
# ---
37+
# name: test_all_entities[camera.vivotek_camera-state]
38+
StateSnapshot({
39+
'attributes': ReadOnlyDict({
40+
'access_token': '1caab5c3b3',
41+
'brand': 'VIVOTEK',
42+
'entity_picture': '/api/camera_proxy/camera.vivotek_camera?token=1caab5c3b3',
43+
'friendly_name': 'Vivotek Camera',
44+
'supported_features': <CameraEntityFeature: 2>,
45+
}),
46+
'context': <ANY>,
47+
'entity_id': 'camera.vivotek_camera',
48+
'last_changed': <ANY>,
49+
'last_reported': <ANY>,
50+
'last_updated': <ANY>,
51+
'state': 'idle',
52+
})
53+
# ---
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"""Tests for the Vivotek camera integration."""
2+
3+
from unittest.mock import AsyncMock, patch
4+
5+
from syrupy.assertion import SnapshotAssertion
6+
7+
from homeassistant.core import HomeAssistant
8+
from homeassistant.helpers import entity_registry as er
9+
10+
from . import setup_integration
11+
12+
from tests.common import MockConfigEntry, snapshot_platform
13+
14+
15+
async def test_all_entities(
16+
hass: HomeAssistant,
17+
snapshot: SnapshotAssertion,
18+
mock_vivotek_camera: AsyncMock,
19+
mock_config_entry: MockConfigEntry,
20+
entity_registry: er.EntityRegistry,
21+
) -> None:
22+
"""Test all entities."""
23+
with patch("random.SystemRandom.getrandbits", return_value=123123123123):
24+
await setup_integration(hass, mock_config_entry)
25+
26+
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)

0 commit comments

Comments
 (0)