Add discovery support to unifiprotect (#64340)
This commit is contained in:
parent
81461832c3
commit
88261c6c14
14 changed files with 450 additions and 26 deletions
|
@ -23,6 +23,8 @@ from homeassistant.helpers import entity_registry as er
|
|||
from homeassistant.helpers.entity import EntityDescription
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
from . import _patch_discovery
|
||||
|
||||
from tests.common import MockConfigEntry, async_fire_time_changed, load_fixture
|
||||
|
||||
MAC_ADDR = "aa:bb:cc:dd:ee:ff"
|
||||
|
@ -73,6 +75,24 @@ def mock_nvr_fixture():
|
|||
NVR.__config__.validate_assignment = True
|
||||
|
||||
|
||||
@pytest.fixture(name="mock_ufp_config_entry")
|
||||
def mock_ufp_config_entry():
|
||||
"""Mock the unifiprotect config entry."""
|
||||
|
||||
return MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
data={
|
||||
"host": "1.1.1.1",
|
||||
"username": "test-username",
|
||||
"password": "test-password",
|
||||
"id": "UnifiProtect",
|
||||
"port": 443,
|
||||
"verify_ssl": False,
|
||||
},
|
||||
version=2,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(name="mock_old_nvr")
|
||||
def mock_old_nvr_fixture():
|
||||
"""Mock UniFi Protect Camera device."""
|
||||
|
@ -122,28 +142,20 @@ def mock_client(mock_bootstrap: MockBootstrap):
|
|||
|
||||
@pytest.fixture
|
||||
def mock_entry(
|
||||
hass: HomeAssistant, mock_client # pylint: disable=redefined-outer-name
|
||||
hass: HomeAssistant,
|
||||
mock_ufp_config_entry: MockConfigEntry,
|
||||
mock_client, # pylint: disable=redefined-outer-name
|
||||
):
|
||||
"""Mock ProtectApiClient for testing."""
|
||||
|
||||
with patch("homeassistant.components.unifiprotect.ProtectApiClient") as mock_api:
|
||||
mock_config = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
data={
|
||||
"host": "1.1.1.1",
|
||||
"username": "test-username",
|
||||
"password": "test-password",
|
||||
"id": "UnifiProtect",
|
||||
"port": 443,
|
||||
"verify_ssl": False,
|
||||
},
|
||||
version=2,
|
||||
)
|
||||
mock_config.add_to_hass(hass)
|
||||
with _patch_discovery(no_device=True), patch(
|
||||
"homeassistant.components.unifiprotect.ProtectApiClient"
|
||||
) as mock_api:
|
||||
mock_ufp_config_entry.add_to_hass(hass)
|
||||
|
||||
mock_api.return_value = mock_client
|
||||
|
||||
yield MockEntityFixture(mock_config, mock_client)
|
||||
yield MockEntityFixture(mock_ufp_config_entry, mock_client)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue