Improve type hints in lovelace tests (#121520)

This commit is contained in:
epenet 2024-07-08 14:04:11 +02:00 committed by GitHub
parent 19e272a901
commit 98651cbd2e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,6 +1,6 @@
"""Test the Lovelace Cast platform."""
from collections.abc import Generator
from collections.abc import AsyncGenerator, Generator
from time import time
from unittest.mock import MagicMock, patch
@ -30,7 +30,7 @@ def mock_onboarding_done() -> Generator[MagicMock]:
@pytest.fixture
async def mock_https_url(hass):
async def mock_https_url(hass: HomeAssistant) -> None:
"""Mock valid URL."""
await async_process_ha_core_config(
hass,
@ -39,7 +39,7 @@ async def mock_https_url(hass):
@pytest.fixture
async def mock_yaml_dashboard(hass):
async def mock_yaml_dashboard(hass: HomeAssistant) -> AsyncGenerator[None]:
"""Mock the content of a YAML dashboard."""
# Set up a YAML dashboard with 2 views.
assert await async_setup_component(
@ -116,9 +116,8 @@ async def test_browse_media_error(hass: HomeAssistant) -> None:
)
async def test_browse_media(
hass: HomeAssistant, mock_yaml_dashboard, mock_https_url
) -> None:
@pytest.mark.usefixtures("mock_yaml_dashboard", "mock_https_url")
async def test_browse_media(hass: HomeAssistant) -> None:
"""Test browse media."""
top_level_items = await lovelace_cast.async_browse_media(
hass, "lovelace", "", lovelace_cast.CAST_TYPE_CHROMECAST
@ -181,7 +180,8 @@ async def test_browse_media(
)
async def test_play_media(hass: HomeAssistant, mock_yaml_dashboard) -> None:
@pytest.mark.usefixtures("mock_yaml_dashboard")
async def test_play_media(hass: HomeAssistant) -> None:
"""Test playing media."""
calls = async_mock_service(hass, "cast", "show_lovelace_view")