Add missing mock in coronavirus config flow tests (#89428)

This commit is contained in:
epenet 2023-03-09 13:16:36 +01:00 committed by GitHub
parent c6d2824afe
commit 4a082403eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 5 deletions

View File

@ -1,10 +1,19 @@
"""Test helpers.""" """Test helpers."""
from collections.abc import Generator
from unittest.mock import Mock, patch from unittest.mock import AsyncMock, Mock, patch
import pytest 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) @pytest.fixture(autouse=True)
def mock_cases(): def mock_cases():
"""Mock coronavirus cases.""" """Mock coronavirus cases."""

View File

@ -1,14 +1,17 @@
"""Test the Coronavirus config flow.""" """Test the Coronavirus config flow."""
from unittest.mock import MagicMock, patch from unittest.mock import AsyncMock, MagicMock, patch
from aiohttp import ClientError from aiohttp import ClientError
import pytest
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.components.coronavirus.const import DOMAIN, OPTION_WORLDWIDE from homeassistant.components.coronavirus.const import DOMAIN, OPTION_WORLDWIDE
from homeassistant.core import HomeAssistant 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.""" """Test we get the form."""
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
@ -28,7 +31,7 @@ async def test_form(hass: HomeAssistant) -> None:
"country": OPTION_WORLDWIDE, "country": OPTION_WORLDWIDE,
} }
await hass.async_block_till_done() await hass.async_block_till_done()
assert len(hass.states.async_all()) == 4 mock_setup_entry.assert_called_once()
@patch( @patch(