Clean up patching of setup platforms for UniFi Protect integration (#63156)

This commit is contained in:
Christopher Bailey 2021-12-31 17:20:23 -05:00 committed by GitHub
parent 0dee4f85f0
commit b379acc119
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 45 additions and 47 deletions

View file

@ -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")