Add missing mock in aemet config flow tests (#89360)
This commit is contained in:
parent
33906059d3
commit
3e2ee7cd11
2 changed files with 20 additions and 6 deletions
14
tests/components/aemet/conftest.py
Normal file
14
tests/components/aemet/conftest.py
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
"""Test fixtures for aemet."""
|
||||||
|
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.aemet.async_setup_entry", return_value=True
|
||||||
|
) as mock_setup_entry:
|
||||||
|
yield mock_setup_entry
|
|
@ -1,6 +1,7 @@
|
||||||
"""Define tests for the AEMET OpenData config flow."""
|
"""Define tests for the AEMET OpenData config flow."""
|
||||||
from unittest.mock import MagicMock, patch
|
from unittest.mock import AsyncMock, MagicMock, patch
|
||||||
|
|
||||||
|
import pytest
|
||||||
import requests_mock
|
import requests_mock
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
from homeassistant import data_entry_flow
|
||||||
|
@ -14,6 +15,8 @@ from .util import aemet_requests_mock
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
|
pytestmark = pytest.mark.usefixtures("mock_setup_entry")
|
||||||
|
|
||||||
CONFIG = {
|
CONFIG = {
|
||||||
CONF_NAME: "aemet",
|
CONF_NAME: "aemet",
|
||||||
CONF_API_KEY: "foo",
|
CONF_API_KEY: "foo",
|
||||||
|
@ -22,13 +25,10 @@ CONFIG = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async def test_form(hass: HomeAssistant) -> None:
|
async def test_form(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None:
|
||||||
"""Test that the form is served with valid input."""
|
"""Test that the form is served with valid input."""
|
||||||
|
|
||||||
with patch(
|
with requests_mock.mock() as _m:
|
||||||
"homeassistant.components.aemet.async_setup_entry",
|
|
||||||
return_value=True,
|
|
||||||
) as mock_setup_entry, requests_mock.mock() as _m:
|
|
||||||
aemet_requests_mock(_m)
|
aemet_requests_mock(_m)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
|
|
Loading…
Add table
Reference in a new issue