Add missing mock in atag config flow tests (#89356)

This commit is contained in:
epenet 2023-03-08 16:16:51 +01:00 committed by GitHub
parent ea6a95176d
commit f4572a2e1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 2 deletions

View File

@ -1,10 +1,20 @@
"""Provide common Atag fixtures.""" """Provide common Atag fixtures."""
import asyncio import asyncio
from unittest.mock import patch from collections.abc import Generator
from unittest.mock import AsyncMock, patch
import pytest import pytest
@pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
"""Override async_setup_entry."""
with patch(
"homeassistant.components.atag.async_setup_entry", return_value=True
) as mock_setup_entry:
yield mock_setup_entry
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
async def mock_pyatag_sleep(): async def mock_pyatag_sleep():
"""Mock out pyatag sleeps.""" """Mock out pyatag sleeps."""

View File

@ -1,6 +1,8 @@
"""Tests for the Atag config flow.""" """Tests for the Atag config flow."""
from unittest.mock import PropertyMock, patch from unittest.mock import PropertyMock, patch
import pytest
from homeassistant import config_entries, data_entry_flow from homeassistant import config_entries, data_entry_flow
from homeassistant.components.atag import DOMAIN from homeassistant.components.atag import DOMAIN
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -9,6 +11,8 @@ from . import UID, USER_INPUT, init_integration, mock_connection
from tests.test_util.aiohttp import AiohttpClientMocker from tests.test_util.aiohttp import AiohttpClientMocker
pytestmark = pytest.mark.usefixtures("mock_setup_entry")
async def test_show_form( async def test_show_form(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
@ -27,7 +31,9 @@ async def test_adding_second_device(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None: ) -> None:
"""Test that only one Atag configuration is allowed.""" """Test that only one Atag configuration is allowed."""
await init_integration(hass, aioclient_mock) entry = await init_integration(hass, aioclient_mock)
entry.unique_id = UID
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=USER_INPUT DOMAIN, context={"source": config_entries.SOURCE_USER}, data=USER_INPUT
) )