Annotate parametrized arcam_fmj media_player test signatures (#171163)

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Josh Gustafson
2026-05-18 18:57:24 -06:00
committed by GitHub
parent e20f4c8f6e
commit f75c205c08
+38 -14
View File
@@ -1,5 +1,6 @@
"""Tests for arcam fmj receivers."""
from collections.abc import Generator
from math import isclose
from unittest.mock import Mock, PropertyMock, patch
@@ -46,7 +47,7 @@ from tests.common import MockConfigEntry, snapshot_platform
@pytest.fixture(autouse=True)
def platform_fixture():
def platform_fixture() -> Generator[None]:
"""Only test single platform."""
with patch("homeassistant.components.arcam_fmj.PLATFORMS", [Platform.MEDIA_PLAYER]):
yield
@@ -365,7 +366,11 @@ async def test_play_media_invalid(hass: HomeAssistant, state_1: State) -> None:
)
@pytest.mark.usefixtures("player_setup")
async def test_sound_mode(
hass: HomeAssistant, client: Mock, state_1: State, mode, mode_enum
hass: HomeAssistant,
client: Mock,
state_1: State,
mode: str | None,
mode_enum: DecodeMode2CH | DecodeModeMCH | None,
) -> None:
"""Test selection sound mode."""
state_1.get_decode_mode.return_value = mode_enum
@@ -383,7 +388,11 @@ async def test_sound_mode(
)
@pytest.mark.usefixtures("player_setup")
async def test_sound_mode_list(
hass: HomeAssistant, client: Mock, state_1: State, modes, modes_enum
hass: HomeAssistant,
client: Mock,
state_1: State,
modes: list[str] | None,
modes_enum: list[DecodeMode2CH] | list[DecodeModeMCH] | None,
) -> None:
"""Test sound mode list."""
state_1.get_decode_modes.return_value = modes_enum
@@ -432,10 +441,9 @@ async def test_volume_level(hass: HomeAssistant, client: Mock, state_1: State) -
@pytest.mark.parametrize(("volume", "call"), [(0.0, 0), (0.5, 50), (1.0, 99)])
@pytest.mark.usefixtures("player_setup")
async def test_set_volume_level(
hass: HomeAssistant, state_1: State, volume, call
hass: HomeAssistant, state_1: State, volume: float, call: int
) -> None:
"""Test setting volume."""
await hass.services.async_call(
"media_player",
SERVICE_VOLUME_SET,
@@ -478,7 +486,11 @@ async def test_set_volume_level_lost(hass: HomeAssistant, state_1: State) -> Non
)
@pytest.mark.usefixtures("player_setup")
async def test_media_content_type(
hass: HomeAssistant, client: Mock, state_1: State, source, media_content_type
hass: HomeAssistant,
client: Mock,
state_1: State,
source: SourceCodes | None,
media_content_type: MediaType | None,
) -> None:
"""Test content type deduction."""
state_1.get_source.return_value = source
@@ -498,7 +510,13 @@ async def test_media_content_type(
)
@pytest.mark.usefixtures("player_setup")
async def test_media_channel(
hass: HomeAssistant, client: Mock, state_1: State, source, dab, rds, channel
hass: HomeAssistant,
client: Mock,
state_1: State,
source: SourceCodes,
dab: str | None,
rds: str | None,
channel: str | None,
) -> None:
"""Test media channel."""
state_1.get_dab_station.return_value = dab
@@ -518,7 +536,12 @@ async def test_media_channel(
)
@pytest.mark.usefixtures("player_setup")
async def test_media_artist(
hass: HomeAssistant, client: Mock, state_1: State, source, dls, artist
hass: HomeAssistant,
client: Mock,
state_1: State,
source: SourceCodes,
dls: str | None,
artist: str | None,
) -> None:
"""Test media artist."""
state_1.get_dls_pdt.return_value = dls
@@ -537,17 +560,18 @@ async def test_media_artist(
)
@pytest.mark.usefixtures("player_setup")
async def test_media_title(
hass: HomeAssistant, client: Mock, state_1: State, source, channel, title
hass: HomeAssistant,
client: Mock,
state_1: State,
source: SourceCodes | None,
channel: str | None,
title: str | None,
) -> None:
"""Test media title."""
state_1.get_source.return_value = source
with patch.object(
ArcamFmj, "media_channel", new_callable=PropertyMock
) as media_channel:
media_channel.return_value = channel
data = await update(hass, client, MOCK_ENTITY_ID)
if title is None:
assert "media_title" not in data.attributes
else:
assert data.attributes["media_title"] == title
assert data.attributes.get("media_title") == title