Use snapshot assertion for onvif diagnostics test (#98982)
This commit is contained in:
parent
54ed8fc914
commit
4d8941d4b7
2 changed files with 80 additions and 78 deletions
74
tests/components/onvif/snapshots/test_diagnostics.ambr
Normal file
74
tests/components/onvif/snapshots/test_diagnostics.ambr
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
# serializer version: 1
|
||||||
|
# name: test_diagnostics
|
||||||
|
dict({
|
||||||
|
'config': dict({
|
||||||
|
'data': dict({
|
||||||
|
'host': '**REDACTED**',
|
||||||
|
'name': 'TestCamera',
|
||||||
|
'password': '**REDACTED**',
|
||||||
|
'port': 80,
|
||||||
|
'snapshot_auth': 'digest',
|
||||||
|
'username': '**REDACTED**',
|
||||||
|
}),
|
||||||
|
'disabled_by': None,
|
||||||
|
'domain': 'onvif',
|
||||||
|
'entry_id': '1',
|
||||||
|
'options': dict({
|
||||||
|
'enable_webhooks': True,
|
||||||
|
'extra_arguments': '-pred 1',
|
||||||
|
'rtsp_transport': 'tcp',
|
||||||
|
}),
|
||||||
|
'pref_disable_new_entities': False,
|
||||||
|
'pref_disable_polling': False,
|
||||||
|
'source': 'user',
|
||||||
|
'title': 'Mock Title',
|
||||||
|
'unique_id': 'aa:bb:cc:dd:ee',
|
||||||
|
'version': 1,
|
||||||
|
}),
|
||||||
|
'device': dict({
|
||||||
|
'capabilities': dict({
|
||||||
|
'events': False,
|
||||||
|
'imaging': True,
|
||||||
|
'ptz': True,
|
||||||
|
'snapshot': False,
|
||||||
|
}),
|
||||||
|
'info': dict({
|
||||||
|
'fw_version': 'TestFirmwareVersion',
|
||||||
|
'mac': 'aa:bb:cc:dd:ee',
|
||||||
|
'manufacturer': 'TestManufacturer',
|
||||||
|
'model': 'TestModel',
|
||||||
|
'serial_number': 'ABCDEFGHIJK',
|
||||||
|
}),
|
||||||
|
'profiles': list([
|
||||||
|
dict({
|
||||||
|
'index': 0,
|
||||||
|
'name': 'profile1',
|
||||||
|
'ptz': None,
|
||||||
|
'token': 'dummy',
|
||||||
|
'video': dict({
|
||||||
|
'encoding': 'any',
|
||||||
|
'resolution': dict({
|
||||||
|
'height': 480,
|
||||||
|
'width': 640,
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
'video_source_token': None,
|
||||||
|
}),
|
||||||
|
]),
|
||||||
|
'services': dict({
|
||||||
|
}),
|
||||||
|
'xaddrs': dict({
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
'events': dict({
|
||||||
|
'pullpoint_manager_state': dict({
|
||||||
|
'__type': "<enum 'PullPointManagerState'>",
|
||||||
|
'repr': '<PullPointManagerState.PAUSED: 2>',
|
||||||
|
}),
|
||||||
|
'webhook_manager_state': dict({
|
||||||
|
'__type': "<enum 'WebHookManagerState'>",
|
||||||
|
'repr': '<WebHookManagerState.STARTED: 1>',
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
# ---
|
|
@ -1,93 +1,21 @@
|
||||||
"""Test ONVIF diagnostics."""
|
"""Test ONVIF diagnostics."""
|
||||||
from unittest.mock import ANY
|
from syrupy import SnapshotAssertion
|
||||||
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
from . import (
|
from . import setup_onvif_integration
|
||||||
FIRMWARE_VERSION,
|
|
||||||
MAC,
|
|
||||||
MANUFACTURER,
|
|
||||||
MODEL,
|
|
||||||
SERIAL_NUMBER,
|
|
||||||
setup_onvif_integration,
|
|
||||||
)
|
|
||||||
|
|
||||||
from tests.components.diagnostics import get_diagnostics_for_config_entry
|
from tests.components.diagnostics import get_diagnostics_for_config_entry
|
||||||
from tests.typing import ClientSessionGenerator
|
from tests.typing import ClientSessionGenerator
|
||||||
|
|
||||||
|
|
||||||
async def test_diagnostics(
|
async def test_diagnostics(
|
||||||
hass: HomeAssistant, hass_client: ClientSessionGenerator
|
hass: HomeAssistant,
|
||||||
|
hass_client: ClientSessionGenerator,
|
||||||
|
snapshot: SnapshotAssertion,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test generating diagnostics for a config entry."""
|
"""Test generating diagnostics for a config entry."""
|
||||||
|
|
||||||
entry, _, _ = await setup_onvif_integration(hass)
|
entry, _, _ = await setup_onvif_integration(hass)
|
||||||
|
|
||||||
diag = await get_diagnostics_for_config_entry(hass, hass_client, entry)
|
assert await get_diagnostics_for_config_entry(hass, hass_client, entry) == snapshot
|
||||||
|
|
||||||
assert diag == {
|
|
||||||
"config": {
|
|
||||||
"entry_id": "1",
|
|
||||||
"version": 1,
|
|
||||||
"domain": "onvif",
|
|
||||||
"title": "Mock Title",
|
|
||||||
"data": {
|
|
||||||
"name": "TestCamera",
|
|
||||||
"host": "**REDACTED**",
|
|
||||||
"port": 80,
|
|
||||||
"username": "**REDACTED**",
|
|
||||||
"password": "**REDACTED**",
|
|
||||||
"snapshot_auth": "digest",
|
|
||||||
},
|
|
||||||
"options": {
|
|
||||||
"extra_arguments": "-pred 1",
|
|
||||||
"rtsp_transport": "tcp",
|
|
||||||
"enable_webhooks": True,
|
|
||||||
},
|
|
||||||
"pref_disable_new_entities": False,
|
|
||||||
"pref_disable_polling": False,
|
|
||||||
"source": "user",
|
|
||||||
"unique_id": "aa:bb:cc:dd:ee",
|
|
||||||
"disabled_by": None,
|
|
||||||
},
|
|
||||||
"device": {
|
|
||||||
"info": {
|
|
||||||
"manufacturer": MANUFACTURER,
|
|
||||||
"model": MODEL,
|
|
||||||
"fw_version": FIRMWARE_VERSION,
|
|
||||||
"serial_number": SERIAL_NUMBER,
|
|
||||||
"mac": MAC,
|
|
||||||
},
|
|
||||||
"capabilities": {
|
|
||||||
"snapshot": False,
|
|
||||||
"events": False,
|
|
||||||
"ptz": True,
|
|
||||||
"imaging": True,
|
|
||||||
},
|
|
||||||
"profiles": [
|
|
||||||
{
|
|
||||||
"index": 0,
|
|
||||||
"token": "dummy",
|
|
||||||
"name": "profile1",
|
|
||||||
"video": {
|
|
||||||
"encoding": "any",
|
|
||||||
"resolution": {"width": 640, "height": 480},
|
|
||||||
},
|
|
||||||
"ptz": None,
|
|
||||||
"video_source_token": None,
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"services": ANY,
|
|
||||||
"xaddrs": ANY,
|
|
||||||
},
|
|
||||||
"events": {
|
|
||||||
"pullpoint_manager_state": {
|
|
||||||
"__type": "<enum 'PullPointManagerState'>",
|
|
||||||
"repr": "<PullPointManagerState.PAUSED: 2>",
|
|
||||||
},
|
|
||||||
"webhook_manager_state": {
|
|
||||||
"__type": "<enum 'WebHookManagerState'>",
|
|
||||||
"repr": "<WebHookManagerState.STARTED: 1>",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue