diff --git a/tests/components/atag/conftest.py b/tests/components/atag/conftest.py index 7df3bfecf11..a1270696540 100644 --- a/tests/components/atag/conftest.py +++ b/tests/components/atag/conftest.py @@ -1,10 +1,20 @@ """Provide common Atag fixtures.""" import asyncio -from unittest.mock import patch +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.atag.async_setup_entry", return_value=True + ) as mock_setup_entry: + yield mock_setup_entry + + @pytest.fixture(autouse=True) async def mock_pyatag_sleep(): """Mock out pyatag sleeps.""" diff --git a/tests/components/atag/test_config_flow.py b/tests/components/atag/test_config_flow.py index 87435b66a77..8dc73741e90 100644 --- a/tests/components/atag/test_config_flow.py +++ b/tests/components/atag/test_config_flow.py @@ -1,6 +1,8 @@ """Tests for the Atag config flow.""" from unittest.mock import PropertyMock, patch +import pytest + from homeassistant import config_entries, data_entry_flow from homeassistant.components.atag import DOMAIN 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 +pytestmark = pytest.mark.usefixtures("mock_setup_entry") + async def test_show_form( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker @@ -27,7 +31,9 @@ async def test_adding_second_device( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker ) -> None: """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( DOMAIN, context={"source": config_entries.SOURCE_USER}, data=USER_INPUT )