mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 06:07:17 +00:00
Improve type hints in lovelace tests (#121520)
This commit is contained in:
parent
19e272a901
commit
98651cbd2e
@ -1,6 +1,6 @@
|
|||||||
"""Test the Lovelace Cast platform."""
|
"""Test the Lovelace Cast platform."""
|
||||||
|
|
||||||
from collections.abc import Generator
|
from collections.abc import AsyncGenerator, Generator
|
||||||
from time import time
|
from time import time
|
||||||
from unittest.mock import MagicMock, patch
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ def mock_onboarding_done() -> Generator[MagicMock]:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
async def mock_https_url(hass):
|
async def mock_https_url(hass: HomeAssistant) -> None:
|
||||||
"""Mock valid URL."""
|
"""Mock valid URL."""
|
||||||
await async_process_ha_core_config(
|
await async_process_ha_core_config(
|
||||||
hass,
|
hass,
|
||||||
@ -39,7 +39,7 @@ async def mock_https_url(hass):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
async def mock_yaml_dashboard(hass):
|
async def mock_yaml_dashboard(hass: HomeAssistant) -> AsyncGenerator[None]:
|
||||||
"""Mock the content of a YAML dashboard."""
|
"""Mock the content of a YAML dashboard."""
|
||||||
# Set up a YAML dashboard with 2 views.
|
# Set up a YAML dashboard with 2 views.
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
@ -116,9 +116,8 @@ async def test_browse_media_error(hass: HomeAssistant) -> None:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def test_browse_media(
|
@pytest.mark.usefixtures("mock_yaml_dashboard", "mock_https_url")
|
||||||
hass: HomeAssistant, mock_yaml_dashboard, mock_https_url
|
async def test_browse_media(hass: HomeAssistant) -> None:
|
||||||
) -> None:
|
|
||||||
"""Test browse media."""
|
"""Test browse media."""
|
||||||
top_level_items = await lovelace_cast.async_browse_media(
|
top_level_items = await lovelace_cast.async_browse_media(
|
||||||
hass, "lovelace", "", lovelace_cast.CAST_TYPE_CHROMECAST
|
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."""
|
"""Test playing media."""
|
||||||
calls = async_mock_service(hass, "cast", "show_lovelace_view")
|
calls = async_mock_service(hass, "cast", "show_lovelace_view")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user