Add missing mock in brunt config flow tests (#88834)

This commit is contained in:
epenet 2023-02-27 14:01:09 +01:00 committed by GitHub
parent aeb6c4f078
commit 76819fbb23
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 6 deletions

View file

@ -0,0 +1,14 @@
"""Configuration for brunt tests."""
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.brunt.async_setup_entry", return_value=True
) as mock_setup_entry:
yield mock_setup_entry

View file

@ -1,5 +1,5 @@
"""Test the Brunt config flow.""" """Test the Brunt config flow."""
from unittest.mock import Mock, patch from unittest.mock import AsyncMock, Mock, patch
from aiohttp import ClientResponseError from aiohttp import ClientResponseError
from aiohttp.client_exceptions import ServerDisconnectedError from aiohttp.client_exceptions import ServerDisconnectedError
@ -14,8 +14,10 @@ from tests.common import MockConfigEntry
CONFIG = {CONF_USERNAME: "test-username", CONF_PASSWORD: "test-password"} CONFIG = {CONF_USERNAME: "test-username", CONF_PASSWORD: "test-password"}
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(
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=None DOMAIN, context={"source": config_entries.SOURCE_USER}, data=None
@ -26,10 +28,7 @@ async def test_form(hass: HomeAssistant) -> None:
with patch( with patch(
"homeassistant.components.brunt.config_flow.BruntClientAsync.async_login", "homeassistant.components.brunt.config_flow.BruntClientAsync.async_login",
return_value=None, return_value=None,
), patch( ):
"homeassistant.components.brunt.async_setup_entry",
return_value=True,
) as mock_setup_entry:
result2 = await hass.config_entries.flow.async_configure( result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], result["flow_id"],
CONFIG, CONFIG,