Add missing mock in aemet config flow tests (#89360)

This commit is contained in:
epenet 2023-03-08 16:18:44 +01:00 committed by GitHub
parent 33906059d3
commit 3e2ee7cd11
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 6 deletions

View 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

View file

@ -1,6 +1,7 @@
"""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
from homeassistant import data_entry_flow
@ -14,6 +15,8 @@ from .util import aemet_requests_mock
from tests.common import MockConfigEntry
pytestmark = pytest.mark.usefixtures("mock_setup_entry")
CONFIG = {
CONF_NAME: "aemet",
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."""
with patch(
"homeassistant.components.aemet.async_setup_entry",
return_value=True,
) as mock_setup_entry, requests_mock.mock() as _m:
with requests_mock.mock() as _m:
aemet_requests_mock(_m)
result = await hass.config_entries.flow.async_init(