Clean up patching of setup platforms for UniFi Protect integration (#63156)
This commit is contained in:
parent
0dee4f85f0
commit
b379acc119
5 changed files with 45 additions and 47 deletions
|
@ -2,7 +2,7 @@
|
|||
# pylint: disable=protected-access
|
||||
from __future__ import annotations
|
||||
|
||||
from unittest.mock import AsyncMock, patch
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
import pytest
|
||||
from pyunifiprotect.data import Camera
|
||||
|
@ -12,7 +12,7 @@ from homeassistant.const import ATTR_ATTRIBUTION, ATTR_ENTITY_ID, Platform
|
|||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from .conftest import MockEntityFixture, enable_entity
|
||||
from .conftest import MockEntityFixture, assert_entity_counts, enable_entity
|
||||
|
||||
|
||||
@pytest.fixture(name="camera")
|
||||
|
@ -32,14 +32,10 @@ async def camera_fixture(
|
|||
camera_obj.id: camera_obj,
|
||||
}
|
||||
|
||||
with patch("homeassistant.components.unifiprotect.PLATFORMS", [Platform.BUTTON]):
|
||||
await hass.config_entries.async_setup(mock_entry.entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
await hass.config_entries.async_setup(mock_entry.entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
entity_registry = er.async_get(hass)
|
||||
|
||||
assert len(hass.states.async_all()) == 0
|
||||
assert len(entity_registry.entities) == 1
|
||||
assert_entity_counts(hass, Platform.BUTTON, 1, 0)
|
||||
|
||||
yield (camera_obj, "button.test_camera_reboot_device")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue