mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Add missing mock in coronavirus config flow tests (#89428)
This commit is contained in:
parent
c6d2824afe
commit
4a082403eb
@ -1,10 +1,19 @@
|
||||
"""Test helpers."""
|
||||
|
||||
from unittest.mock import Mock, patch
|
||||
from collections.abc import Generator
|
||||
from unittest.mock import AsyncMock, Mock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
||||
"""Override async_setup_entry."""
|
||||
with patch(
|
||||
"homeassistant.components.coronavirus.async_setup_entry", return_value=True
|
||||
) as mock_setup_entry:
|
||||
yield mock_setup_entry
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def mock_cases():
|
||||
"""Mock coronavirus cases."""
|
||||
|
@ -1,14 +1,17 @@
|
||||
"""Test the Coronavirus config flow."""
|
||||
from unittest.mock import MagicMock, patch
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
|
||||
from aiohttp import ClientError
|
||||
import pytest
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.coronavirus.const import DOMAIN, OPTION_WORLDWIDE
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
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."""
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@ -28,7 +31,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||
"country": OPTION_WORLDWIDE,
|
||||
}
|
||||
await hass.async_block_till_done()
|
||||
assert len(hass.states.async_all()) == 4
|
||||
mock_setup_entry.assert_called_once()
|
||||
|
||||
|
||||
@patch(
|
||||
|
Loading…
x
Reference in New Issue
Block a user