parent
d5f883fbf0
commit
ea7f2af966
2 changed files with 11 additions and 2 deletions
|
@ -60,6 +60,7 @@ def blink_api_fixture(camera) -> MagicMock:
|
||||||
mock_blink_api.refresh = AsyncMock(return_value=True)
|
mock_blink_api.refresh = AsyncMock(return_value=True)
|
||||||
mock_blink_api.sync = MagicMock(return_value=True)
|
mock_blink_api.sync = MagicMock(return_value=True)
|
||||||
mock_blink_api.cameras = {camera.name: camera}
|
mock_blink_api.cameras = {camera.name: camera}
|
||||||
|
mock_blink_api.request_homescreen = AsyncMock(return_value=True)
|
||||||
|
|
||||||
with patch("homeassistant.components.blink.Blink") as class_mock:
|
with patch("homeassistant.components.blink.Blink") as class_mock:
|
||||||
class_mock.return_value = mock_blink_api
|
class_mock.return_value = mock_blink_api
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
"""Test the Blink init."""
|
"""Test the Blink init."""
|
||||||
|
|
||||||
from unittest.mock import AsyncMock, MagicMock
|
from unittest.mock import AsyncMock, MagicMock, patch
|
||||||
|
|
||||||
from aiohttp import ClientError
|
from aiohttp import ClientError
|
||||||
|
from blinkpy.auth import LoginError
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components.blink.const import (
|
from homeassistant.components.blink.const import (
|
||||||
|
@ -53,9 +54,16 @@ async def test_setup_not_ready_authkey_required(
|
||||||
"""Test setup failed because 2FA is needed to connect to the Blink system."""
|
"""Test setup failed because 2FA is needed to connect to the Blink system."""
|
||||||
|
|
||||||
mock_blink_auth_api.check_key_required = MagicMock(return_value=True)
|
mock_blink_auth_api.check_key_required = MagicMock(return_value=True)
|
||||||
|
mock_blink_auth_api.send_auth_key = AsyncMock(return_value=False)
|
||||||
|
|
||||||
mock_config_entry.add_to_hass(hass)
|
mock_config_entry.add_to_hass(hass)
|
||||||
|
with patch(
|
||||||
|
"homeassistant.components.blink.config_flow.Auth.startup",
|
||||||
|
side_effect=LoginError,
|
||||||
|
):
|
||||||
assert not await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
assert not await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert mock_config_entry.state is ConfigEntryState.SETUP_ERROR
|
assert mock_config_entry.state is ConfigEntryState.SETUP_ERROR
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue