Add missing mock in webostv config flow tests (#88913)

This commit is contained in:
epenet 2023-02-28 18:04:40 +01:00 committed by GitHub
parent ee144d34a9
commit ac6bbc2f1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 9 deletions

View File

@ -1,4 +1,5 @@
"""Common fixtures and objects for the LG webOS integration tests.""" """Common fixtures and objects for the LG webOS integration tests."""
from collections.abc import Generator
from unittest.mock import AsyncMock, Mock, patch from unittest.mock import AsyncMock, Mock, patch
import pytest import pytest
@ -10,6 +11,15 @@ from .const import CHANNEL_1, CHANNEL_2, CLIENT_KEY, FAKE_UUID, MOCK_APPS, MOCK_
from tests.common import async_mock_service from tests.common import async_mock_service
@pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
"""Override async_setup_entry."""
with patch(
"homeassistant.components.webostv.async_setup_entry", return_value=True
) as mock_setup_entry:
yield mock_setup_entry
@pytest.fixture @pytest.fixture
def calls(hass): def calls(hass):
"""Track calls to a mock service.""" """Track calls to a mock service."""

View File

@ -1,6 +1,6 @@
"""Test the WebOS Tv config flow.""" """Test the WebOS Tv config flow."""
import dataclasses import dataclasses
from unittest.mock import Mock, patch from unittest.mock import Mock
from aiowebostv import WebOsTvPairError from aiowebostv import WebOsTvPairError
import pytest import pytest
@ -16,6 +16,8 @@ from homeassistant.data_entry_flow import FlowResultType
from . import setup_webostv from . import setup_webostv
from .const import CLIENT_KEY, FAKE_UUID, HOST, MOCK_APPS, MOCK_INPUTS, TV_NAME from .const import CLIENT_KEY, FAKE_UUID, HOST, MOCK_APPS, MOCK_INPUTS, TV_NAME
pytestmark = pytest.mark.usefixtures("mock_setup_entry")
MOCK_USER_CONFIG = { MOCK_USER_CONFIG = {
CONF_HOST: HOST, CONF_HOST: HOST,
CONF_NAME: TV_NAME, CONF_NAME: TV_NAME,
@ -65,10 +67,9 @@ async def test_form(hass: HomeAssistant, client) -> None:
assert result["type"] == FlowResultType.FORM assert result["type"] == FlowResultType.FORM
assert result["step_id"] == "pairing" assert result["step_id"] == "pairing"
with patch("homeassistant.components.webostv.async_setup_entry", return_value=True): result = await hass.config_entries.flow.async_configure(
result = await hass.config_entries.flow.async_configure( result["flow_id"], user_input={}
result["flow_id"], user_input={} )
)
await hass.async_block_till_done() await hass.async_block_till_done()
@ -184,10 +185,9 @@ async def test_form_ssdp(hass: HomeAssistant, client) -> None:
"""Test that the ssdp confirmation form is served.""" """Test that the ssdp confirmation form is served."""
assert client assert client
with patch("homeassistant.components.webostv.async_setup_entry", return_value=True): result = await hass.config_entries.flow.async_init(
result = await hass.config_entries.flow.async_init( DOMAIN, context={CONF_SOURCE: SOURCE_SSDP}, data=MOCK_DISCOVERY_INFO
DOMAIN, context={CONF_SOURCE: SOURCE_SSDP}, data=MOCK_DISCOVERY_INFO )
)
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == FlowResultType.FORM assert result["type"] == FlowResultType.FORM