Add missing mock in axis config flow tests (#89365)
parent
adb4414440
commit
30884f6d17
|
@ -1,8 +1,9 @@
|
||||||
"""Axis conftest."""
|
"""Axis conftest."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from collections.abc import Generator
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from unittest.mock import patch
|
from unittest.mock import AsyncMock, patch
|
||||||
|
|
||||||
from axis.rtsp import Signal, State
|
from axis.rtsp import Signal, State
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -41,6 +42,16 @@ from .const import (
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
from tests.components.light.conftest import mock_light_profiles # noqa: F401
|
from tests.components.light.conftest import mock_light_profiles # noqa: F401
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
||||||
|
"""Override async_setup_entry."""
|
||||||
|
with patch(
|
||||||
|
"homeassistant.components.axis.async_setup_entry", return_value=True
|
||||||
|
) as mock_setup_entry:
|
||||||
|
yield mock_setup_entry
|
||||||
|
|
||||||
|
|
||||||
# Config entry fixtures
|
# Config entry fixtures
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -38,16 +38,15 @@ from tests.common import MockConfigEntry
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(name="mock_config_entry")
|
@pytest.fixture(name="mock_config_entry")
|
||||||
async def mock_config_entry_fixture(hass, config_entry):
|
async def mock_config_entry_fixture(hass, config_entry, mock_setup_entry):
|
||||||
"""Mock config entry and setup entry."""
|
"""Mock config entry and setup entry."""
|
||||||
with patch("homeassistant.components.axis.async_setup_entry", return_value=True):
|
|
||||||
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
yield config_entry
|
return config_entry
|
||||||
|
|
||||||
|
|
||||||
async def test_flow_manual_configuration(
|
async def test_flow_manual_configuration(
|
||||||
hass: HomeAssistant, setup_default_vapix_requests
|
hass: HomeAssistant, setup_default_vapix_requests, mock_setup_entry
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that config flow works."""
|
"""Test that config flow works."""
|
||||||
MockConfigEntry(domain=AXIS_DOMAIN, source=SOURCE_IGNORE).add_to_hass(hass)
|
MockConfigEntry(domain=AXIS_DOMAIN, source=SOURCE_IGNORE).add_to_hass(hass)
|
||||||
|
@ -164,7 +163,7 @@ async def test_flow_fails_cannot_connect(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
|
|
||||||
async def test_flow_create_entry_multiple_existing_entries_of_same_model(
|
async def test_flow_create_entry_multiple_existing_entries_of_same_model(
|
||||||
hass: HomeAssistant, setup_default_vapix_requests
|
hass: HomeAssistant, setup_default_vapix_requests, mock_setup_entry
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that create entry can generate a name with other entries."""
|
"""Test that create entry can generate a name with other entries."""
|
||||||
entry = MockConfigEntry(
|
entry = MockConfigEntry(
|
||||||
|
@ -310,7 +309,11 @@ async def test_reauth_flow_update_configuration(
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_discovery_flow(
|
async def test_discovery_flow(
|
||||||
hass: HomeAssistant, setup_default_vapix_requests, source: str, discovery_info: dict
|
hass: HomeAssistant,
|
||||||
|
setup_default_vapix_requests,
|
||||||
|
source: str,
|
||||||
|
discovery_info: dict,
|
||||||
|
mock_setup_entry,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the different discovery flows for new devices work."""
|
"""Test the different discovery flows for new devices work."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
|
|
Loading…
Reference in New Issue