Add missing mock in kmtronic config flow tests (#89511)
This commit is contained in:
parent
401273dcff
commit
f22fabdd7f
2 changed files with 20 additions and 6 deletions
14
tests/components/kmtronic/conftest.py
Normal file
14
tests/components/kmtronic/conftest.py
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
"""Define fixtures for kmtronic tests."""
|
||||||
|
from collections.abc import Generator
|
||||||
|
from unittest.mock import AsyncMock, patch
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
||||||
|
"""Override async_setup_entry."""
|
||||||
|
with patch(
|
||||||
|
"homeassistant.components.kmtronic.async_setup_entry", return_value=True
|
||||||
|
) as mock_setup_entry:
|
||||||
|
yield mock_setup_entry
|
|
@ -1,8 +1,9 @@
|
||||||
"""Test the kmtronic config flow."""
|
"""Test the kmtronic config flow."""
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
from unittest.mock import Mock, patch
|
from unittest.mock import AsyncMock, Mock, patch
|
||||||
|
|
||||||
from aiohttp import ClientConnectorError, ClientResponseError
|
from aiohttp import ClientConnectorError, ClientResponseError
|
||||||
|
import pytest
|
||||||
|
|
||||||
from homeassistant import config_entries, data_entry_flow
|
from homeassistant import config_entries, data_entry_flow
|
||||||
from homeassistant.components.kmtronic.const import CONF_REVERSE, DOMAIN
|
from homeassistant.components.kmtronic.const import CONF_REVERSE, DOMAIN
|
||||||
|
@ -12,8 +13,10 @@ from homeassistant.core import HomeAssistant
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
from tests.test_util.aiohttp import AiohttpClientMocker
|
from tests.test_util.aiohttp import AiohttpClientMocker
|
||||||
|
|
||||||
|
pytestmark = pytest.mark.usefixtures("mock_setup_entry")
|
||||||
|
|
||||||
async def test_form(hass: HomeAssistant) -> None:
|
|
||||||
|
async def test_form(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None:
|
||||||
"""Test we get the form."""
|
"""Test we get the form."""
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
|
@ -25,10 +28,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.kmtronic.config_flow.KMTronicHubAPI.async_get_status",
|
"homeassistant.components.kmtronic.config_flow.KMTronicHubAPI.async_get_status",
|
||||||
return_value=[Mock()],
|
return_value=[Mock()],
|
||||||
), patch(
|
):
|
||||||
"homeassistant.components.kmtronic.async_setup_entry",
|
|
||||||
return_value=True,
|
|
||||||
) as mock_setup_entry:
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue