mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Add monkeypatch type hints to webostv tests (#121054)
* Add monkeypatch type hints to webostv * Improve
This commit is contained in:
parent
c9240b8e34
commit
73716ea529
@ -295,7 +295,9 @@ async def test_form_abort_uuid_configured(hass: HomeAssistant, client) -> None:
|
||||
assert entry.data[CONF_HOST] == "new_host"
|
||||
|
||||
|
||||
async def test_reauth_successful(hass: HomeAssistant, client, monkeypatch) -> None:
|
||||
async def test_reauth_successful(
|
||||
hass: HomeAssistant, client, monkeypatch: pytest.MonkeyPatch
|
||||
) -> None:
|
||||
"""Test that the reauthorization is successful."""
|
||||
entry = await setup_webostv(hass)
|
||||
assert client
|
||||
@ -331,7 +333,7 @@ async def test_reauth_successful(hass: HomeAssistant, client, monkeypatch) -> No
|
||||
],
|
||||
)
|
||||
async def test_reauth_errors(
|
||||
hass: HomeAssistant, client, monkeypatch, side_effect, reason
|
||||
hass: HomeAssistant, client, monkeypatch: pytest.MonkeyPatch, side_effect, reason
|
||||
) -> None:
|
||||
"""Test reauthorization errors."""
|
||||
entry = await setup_webostv(hass)
|
||||
|
@ -3,6 +3,7 @@
|
||||
from unittest.mock import Mock
|
||||
|
||||
from aiowebostv import WebOsTvPairError
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.webostv.const import DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_REAUTH, ConfigEntryState
|
||||
@ -12,7 +13,9 @@ from homeassistant.core import HomeAssistant
|
||||
from . import setup_webostv
|
||||
|
||||
|
||||
async def test_reauth_setup_entry(hass: HomeAssistant, client, monkeypatch) -> None:
|
||||
async def test_reauth_setup_entry(
|
||||
hass: HomeAssistant, client, monkeypatch: pytest.MonkeyPatch
|
||||
) -> None:
|
||||
"""Test reauth flow triggered by setup entry."""
|
||||
monkeypatch.setattr(client, "is_connected", Mock(return_value=False))
|
||||
monkeypatch.setattr(client, "connect", Mock(side_effect=WebOsTvPairError))
|
||||
@ -32,7 +35,9 @@ async def test_reauth_setup_entry(hass: HomeAssistant, client, monkeypatch) -> N
|
||||
assert flow["context"].get("entry_id") == entry.entry_id
|
||||
|
||||
|
||||
async def test_key_update_setup_entry(hass: HomeAssistant, client, monkeypatch) -> None:
|
||||
async def test_key_update_setup_entry(
|
||||
hass: HomeAssistant, client, monkeypatch: pytest.MonkeyPatch
|
||||
) -> None:
|
||||
"""Test key update from setup entry."""
|
||||
monkeypatch.setattr(client, "client_key", "new_key")
|
||||
entry = await setup_webostv(hass)
|
||||
|
@ -144,7 +144,7 @@ async def test_media_play_pause(hass: HomeAssistant, client) -> None:
|
||||
],
|
||||
)
|
||||
async def test_media_next_previous_track(
|
||||
hass: HomeAssistant, client, service, client_call, monkeypatch
|
||||
hass: HomeAssistant, client, service, client_call, monkeypatch: pytest.MonkeyPatch
|
||||
) -> None:
|
||||
"""Test media next/previous track services."""
|
||||
await setup_webostv(hass)
|
||||
@ -270,7 +270,10 @@ async def test_select_sound_output(hass: HomeAssistant, client) -> None:
|
||||
|
||||
|
||||
async def test_device_info_startup_off(
|
||||
hass: HomeAssistant, client, monkeypatch, device_registry: dr.DeviceRegistry
|
||||
hass: HomeAssistant,
|
||||
client,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
) -> None:
|
||||
"""Test device info when device is off at startup."""
|
||||
monkeypatch.setattr(client, "system_info", None)
|
||||
@ -291,7 +294,10 @@ async def test_device_info_startup_off(
|
||||
|
||||
|
||||
async def test_entity_attributes(
|
||||
hass: HomeAssistant, client, monkeypatch, device_registry: dr.DeviceRegistry
|
||||
hass: HomeAssistant,
|
||||
client,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
) -> None:
|
||||
"""Test entity attributes."""
|
||||
entry = await setup_webostv(hass)
|
||||
@ -383,7 +389,7 @@ async def test_play_media(hass: HomeAssistant, client, media_id, ch_id) -> None:
|
||||
|
||||
|
||||
async def test_update_sources_live_tv_find(
|
||||
hass: HomeAssistant, client, monkeypatch
|
||||
hass: HomeAssistant, client, monkeypatch: pytest.MonkeyPatch
|
||||
) -> None:
|
||||
"""Test finding live TV app id in update sources."""
|
||||
await setup_webostv(hass)
|
||||
@ -466,7 +472,9 @@ async def test_update_sources_live_tv_find(
|
||||
assert len(sources) == 1
|
||||
|
||||
|
||||
async def test_client_disconnected(hass: HomeAssistant, client, monkeypatch) -> None:
|
||||
async def test_client_disconnected(
|
||||
hass: HomeAssistant, client, monkeypatch: pytest.MonkeyPatch
|
||||
) -> None:
|
||||
"""Test error not raised when client is disconnected."""
|
||||
await setup_webostv(hass)
|
||||
monkeypatch.setattr(client, "is_connected", Mock(return_value=False))
|
||||
@ -477,7 +485,10 @@ async def test_client_disconnected(hass: HomeAssistant, client, monkeypatch) ->
|
||||
|
||||
|
||||
async def test_control_error_handling(
|
||||
hass: HomeAssistant, client, caplog: pytest.LogCaptureFixture, monkeypatch
|
||||
hass: HomeAssistant,
|
||||
client,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
"""Test control errors handling."""
|
||||
await setup_webostv(hass)
|
||||
@ -507,7 +518,9 @@ async def test_control_error_handling(
|
||||
)
|
||||
|
||||
|
||||
async def test_supported_features(hass: HomeAssistant, client, monkeypatch) -> None:
|
||||
async def test_supported_features(
|
||||
hass: HomeAssistant, client, monkeypatch: pytest.MonkeyPatch
|
||||
) -> None:
|
||||
"""Test test supported features."""
|
||||
monkeypatch.setattr(client, "sound_output", "lineout")
|
||||
await setup_webostv(hass)
|
||||
@ -565,7 +578,7 @@ async def test_supported_features(hass: HomeAssistant, client, monkeypatch) -> N
|
||||
|
||||
|
||||
async def test_cached_supported_features(
|
||||
hass: HomeAssistant, client, monkeypatch
|
||||
hass: HomeAssistant, client, monkeypatch: pytest.MonkeyPatch
|
||||
) -> None:
|
||||
"""Test test supported features."""
|
||||
monkeypatch.setattr(client, "is_on", False)
|
||||
@ -672,7 +685,7 @@ async def test_cached_supported_features(
|
||||
|
||||
|
||||
async def test_supported_features_no_cache(
|
||||
hass: HomeAssistant, client, monkeypatch
|
||||
hass: HomeAssistant, client, monkeypatch: pytest.MonkeyPatch
|
||||
) -> None:
|
||||
"""Test supported features if device is off and no cache."""
|
||||
monkeypatch.setattr(client, "is_on", False)
|
||||
@ -716,7 +729,7 @@ async def test_get_image_http(
|
||||
client,
|
||||
hass_client_no_auth: ClientSessionGenerator,
|
||||
aioclient_mock: AiohttpClientMocker,
|
||||
monkeypatch,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
"""Test get image via http."""
|
||||
url = "http://something/valid_icon"
|
||||
@ -742,7 +755,7 @@ async def test_get_image_http_error(
|
||||
hass_client_no_auth: ClientSessionGenerator,
|
||||
aioclient_mock: AiohttpClientMocker,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
monkeypatch,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
"""Test get image via http error."""
|
||||
url = "http://something/icon_error"
|
||||
@ -769,7 +782,7 @@ async def test_get_image_https(
|
||||
client,
|
||||
hass_client_no_auth: ClientSessionGenerator,
|
||||
aioclient_mock: AiohttpClientMocker,
|
||||
monkeypatch,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
"""Test get image via http."""
|
||||
url = "https://something/valid_icon_https"
|
||||
@ -789,7 +802,9 @@ async def test_get_image_https(
|
||||
assert content == b"https_image"
|
||||
|
||||
|
||||
async def test_reauth_reconnect(hass: HomeAssistant, client, monkeypatch) -> None:
|
||||
async def test_reauth_reconnect(
|
||||
hass: HomeAssistant, client, monkeypatch: pytest.MonkeyPatch
|
||||
) -> None:
|
||||
"""Test reauth flow triggered by reconnect."""
|
||||
entry = await setup_webostv(hass)
|
||||
monkeypatch.setattr(client, "is_connected", Mock(return_value=False))
|
||||
@ -814,7 +829,9 @@ async def test_reauth_reconnect(hass: HomeAssistant, client, monkeypatch) -> Non
|
||||
assert flow["context"].get("entry_id") == entry.entry_id
|
||||
|
||||
|
||||
async def test_update_media_state(hass: HomeAssistant, client, monkeypatch) -> None:
|
||||
async def test_update_media_state(
|
||||
hass: HomeAssistant, client, monkeypatch: pytest.MonkeyPatch
|
||||
) -> None:
|
||||
"""Test updating media state."""
|
||||
await setup_webostv(hass)
|
||||
|
||||
|
@ -72,7 +72,9 @@ async def test_notify(hass: HomeAssistant, client) -> None:
|
||||
)
|
||||
|
||||
|
||||
async def test_notify_not_connected(hass: HomeAssistant, client, monkeypatch) -> None:
|
||||
async def test_notify_not_connected(
|
||||
hass: HomeAssistant, client, monkeypatch: pytest.MonkeyPatch
|
||||
) -> None:
|
||||
"""Test sending a message when client is not connected."""
|
||||
await setup_webostv(hass)
|
||||
assert hass.services.has_service(NOTIFY_DOMAIN, TV_NAME)
|
||||
@ -95,7 +97,10 @@ async def test_notify_not_connected(hass: HomeAssistant, client, monkeypatch) ->
|
||||
|
||||
|
||||
async def test_icon_not_found(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, client, monkeypatch
|
||||
hass: HomeAssistant,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
client,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
"""Test notify icon not found error."""
|
||||
await setup_webostv(hass)
|
||||
@ -130,7 +135,7 @@ async def test_connection_errors(
|
||||
hass: HomeAssistant,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
client,
|
||||
monkeypatch,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
side_effect,
|
||||
error,
|
||||
) -> None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user