Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use snapshot assertion for onvif diagnostics test #98982

Merged
merged 1 commit into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions tests/components/onvif/snapshots/test_diagnostics.ambr
Original file line number Diff line number Diff line change
@@ -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>',
}),
}),
})
# ---
84 changes: 6 additions & 78 deletions tests/components/onvif/test_diagnostics.py
Original file line number Diff line number Diff line change
@@ -1,93 +1,21 @@
"""Test ONVIF diagnostics."""
from unittest.mock import ANY
from syrupy import SnapshotAssertion

from homeassistant.core import HomeAssistant

from . import (
FIRMWARE_VERSION,
MAC,
MANUFACTURER,
MODEL,
SERIAL_NUMBER,
setup_onvif_integration,
)
from . import setup_onvif_integration

from tests.components.diagnostics import get_diagnostics_for_config_entry
from tests.typing import ClientSessionGenerator


async def test_diagnostics(
hass: HomeAssistant, hass_client: ClientSessionGenerator
hass: HomeAssistant,
hass_client: ClientSessionGenerator,
snapshot: SnapshotAssertion,
) -> None:
"""Test generating diagnostics for a config entry."""

entry, _, _ = await setup_onvif_integration(hass)

diag = await get_diagnostics_for_config_entry(hass, hass_client, entry)

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>",
},
},
}
assert await get_diagnostics_for_config_entry(hass, hass_client, entry) == snapshot