Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions tests/components/brunt/conftest.py
Original file line number Diff line number Diff line change
@@ -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
11 changes: 5 additions & 6 deletions tests/components/brunt/test_config_flow.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Test the Brunt config flow."""
from unittest.mock import Mock, patch
from unittest.mock import AsyncMock, Mock, patch

from aiohttp import ClientResponseError
from aiohttp.client_exceptions import ServerDisconnectedError
Expand All @@ -14,8 +14,10 @@

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."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=None
Expand All @@ -26,10 +28,7 @@ async def test_form(hass: HomeAssistant) -> None:
with patch(
"homeassistant.components.brunt.config_flow.BruntClientAsync.async_login",
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(
result["flow_id"],
CONFIG,
Expand Down