mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 10:17:09 +00:00
Finish ROVA init tests (#114315)
* Finish ROVA init tests * Finish ROVA init tests * Finish ROVA init tests
This commit is contained in:
parent
fc596cde44
commit
5aabb2a920
31
tests/components/rova/snapshots/test_init.ambr
Normal file
31
tests/components/rova/snapshots/test_init.ambr
Normal file
@ -0,0 +1,31 @@
|
||||
# serializer version: 1
|
||||
# name: test_service
|
||||
DeviceRegistryEntrySnapshot({
|
||||
'area_id': None,
|
||||
'config_entries': <ANY>,
|
||||
'configuration_url': None,
|
||||
'connections': set({
|
||||
}),
|
||||
'disabled_by': None,
|
||||
'entry_type': <DeviceEntryType.SERVICE: 'service'>,
|
||||
'hw_version': None,
|
||||
'id': <ANY>,
|
||||
'identifiers': set({
|
||||
tuple(
|
||||
'rova',
|
||||
'8381BE13',
|
||||
),
|
||||
}),
|
||||
'is_new': False,
|
||||
'labels': set({
|
||||
}),
|
||||
'manufacturer': None,
|
||||
'model': None,
|
||||
'name': '8381BE 13',
|
||||
'name_by_user': None,
|
||||
'serial_number': None,
|
||||
'suggested_area': None,
|
||||
'sw_version': None,
|
||||
'via_device_id': None,
|
||||
})
|
||||
# ---
|
@ -2,11 +2,73 @@
|
||||
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import pytest
|
||||
from requests import ConnectTimeout
|
||||
from syrupy import SnapshotAssertion
|
||||
|
||||
from homeassistant.components.rova import DOMAIN
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import issue_registry as ir
|
||||
from homeassistant.helpers import device_registry as dr, issue_registry as ir
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
from tests.components.rova import setup_with_selected_platforms
|
||||
|
||||
|
||||
async def test_reload(
|
||||
hass: HomeAssistant,
|
||||
mock_rova: MagicMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test reloading the integration."""
|
||||
await setup_with_selected_platforms(hass, mock_config_entry, [Platform.SENSOR])
|
||||
|
||||
assert mock_config_entry.state == ConfigEntryState.LOADED
|
||||
|
||||
assert await hass.config_entries.async_unload(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert mock_config_entry.state == ConfigEntryState.NOT_LOADED
|
||||
|
||||
|
||||
async def test_service(
|
||||
hass: HomeAssistant,
|
||||
mock_rova: MagicMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test the Rova service."""
|
||||
await setup_with_selected_platforms(hass, mock_config_entry, [Platform.SENSOR])
|
||||
|
||||
device_entry = device_registry.async_get_device(
|
||||
identifiers={(DOMAIN, mock_config_entry.unique_id)}
|
||||
)
|
||||
assert device_entry is not None
|
||||
assert device_entry == snapshot
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"method",
|
||||
[
|
||||
"is_rova_area",
|
||||
"get_calendar_items",
|
||||
],
|
||||
)
|
||||
async def test_retry_after_failure(
|
||||
hass: HomeAssistant,
|
||||
mock_rova: MagicMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
method: str,
|
||||
) -> None:
|
||||
"""Test we retry after a failure."""
|
||||
getattr(mock_rova, method).side_effect = ConnectTimeout
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
assert not await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert mock_config_entry.state == ConfigEntryState.SETUP_RETRY
|
||||
|
||||
|
||||
async def test_issue_if_not_rova_area(
|
||||
|
Loading…
x
Reference in New Issue
Block a user