mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 05:37:44 +00:00
Add missing mock in buienradar config flow tests (#89420)
This commit is contained in:
parent
86ad8261d8
commit
9faf251321
14
tests/components/buienradar/conftest.py
Normal file
14
tests/components/buienradar/conftest.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
"""Test fixtures for buienradar2."""
|
||||||
|
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.buienradar.async_setup_entry", return_value=True
|
||||||
|
) as mock_setup_entry:
|
||||||
|
yield mock_setup_entry
|
@ -1,5 +1,6 @@
|
|||||||
"""Test the buienradar2 config flow."""
|
"""Test the buienradar2 config flow."""
|
||||||
from unittest.mock import patch
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from homeassistant import config_entries, data_entry_flow
|
from homeassistant import config_entries, data_entry_flow
|
||||||
from homeassistant.components.buienradar.const import DOMAIN
|
from homeassistant.components.buienradar.const import DOMAIN
|
||||||
@ -11,6 +12,8 @@ from tests.common import MockConfigEntry
|
|||||||
TEST_LATITUDE = 51.5288504
|
TEST_LATITUDE = 51.5288504
|
||||||
TEST_LONGITUDE = 5.4002156
|
TEST_LONGITUDE = 5.4002156
|
||||||
|
|
||||||
|
pytestmark = pytest.mark.usefixtures("mock_setup_entry")
|
||||||
|
|
||||||
|
|
||||||
async def test_config_flow_setup_(hass: HomeAssistant) -> None:
|
async def test_config_flow_setup_(hass: HomeAssistant) -> None:
|
||||||
"""Test setup of camera."""
|
"""Test setup of camera."""
|
||||||
@ -22,13 +25,10 @@ async def test_config_flow_setup_(hass: HomeAssistant) -> None:
|
|||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
with patch(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
"homeassistant.components.buienradar.async_setup_entry", return_value=True
|
result["flow_id"],
|
||||||
):
|
{CONF_LATITUDE: TEST_LATITUDE, CONF_LONGITUDE: TEST_LONGITUDE},
|
||||||
result = await hass.config_entries.flow.async_configure(
|
)
|
||||||
result["flow_id"],
|
|
||||||
{CONF_LATITUDE: TEST_LATITUDE, CONF_LONGITUDE: TEST_LONGITUDE},
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] == "create_entry"
|
assert result["type"] == "create_entry"
|
||||||
assert result["title"] == f"{TEST_LATITUDE},{TEST_LONGITUDE}"
|
assert result["title"] == f"{TEST_LATITUDE},{TEST_LONGITUDE}"
|
||||||
@ -92,13 +92,8 @@ async def test_options_flow(hass: HomeAssistant) -> None:
|
|||||||
user_input={"country_code": "BE", "delta": 450, "timeframe": 30},
|
user_input={"country_code": "BE", "delta": 450, "timeframe": 30},
|
||||||
)
|
)
|
||||||
|
|
||||||
with patch(
|
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||||
"homeassistant.components.buienradar.async_setup_entry", return_value=True
|
|
||||||
), patch(
|
|
||||||
"homeassistant.components.buienradar.async_unload_entry", return_value=True
|
|
||||||
):
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
|
||||||
|
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert entry.options == {"country_code": "BE", "delta": 450, "timeframe": 30}
|
assert entry.options == {"country_code": "BE", "delta": 450, "timeframe": 30}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user