mirror of
https://github.com/home-assistant/core.git
synced 2025-07-09 06:17:07 +00:00
Add missing mock in atag config flow tests (#89356)
This commit is contained in:
parent
ea6a95176d
commit
f4572a2e1c
@ -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."""
|
||||
|
@ -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
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user