mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +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."""
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant import config_entries, data_entry_flow
|
||||
from homeassistant.components.buienradar.const import DOMAIN
|
||||
@ -11,6 +12,8 @@ from tests.common import MockConfigEntry
|
||||
TEST_LATITUDE = 51.5288504
|
||||
TEST_LONGITUDE = 5.4002156
|
||||
|
||||
pytestmark = pytest.mark.usefixtures("mock_setup_entry")
|
||||
|
||||
|
||||
async def test_config_flow_setup_(hass: HomeAssistant) -> None:
|
||||
"""Test setup of camera."""
|
||||
@ -22,13 +25,10 @@ async def test_config_flow_setup_(hass: HomeAssistant) -> None:
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {}
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.buienradar.async_setup_entry", return_value=True
|
||||
):
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
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["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},
|
||||
)
|
||||
|
||||
with patch(
|
||||
"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
|
||||
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}
|
||||
|
Loading…
x
Reference in New Issue
Block a user