From c9240b8e34d5991a90894ac17c029b89e5412d01 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 3 Jul 2024 22:49:01 +0200 Subject: [PATCH] Add monkeypatch type hints to switcher_kis tests (#121055) * Add monkeypatch type hints to switch_kis * Improve --- tests/components/switcher_kis/test_button.py | 9 +++++++-- tests/components/switcher_kis/test_climate.py | 16 +++++++--------- tests/components/switcher_kis/test_cover.py | 4 +++- .../components/switcher_kis/test_diagnostics.py | 7 ++++++- tests/components/switcher_kis/test_sensor.py | 4 +++- tests/components/switcher_kis/test_services.py | 2 +- tests/components/switcher_kis/test_switch.py | 6 ++++-- 7 files changed, 31 insertions(+), 17 deletions(-) diff --git a/tests/components/switcher_kis/test_button.py b/tests/components/switcher_kis/test_button.py index 264c163e111..d0604487370 100644 --- a/tests/components/switcher_kis/test_button.py +++ b/tests/components/switcher_kis/test_button.py @@ -63,7 +63,12 @@ async def test_assume_button( ) @pytest.mark.parametrize("mock_bridge", [[DEVICE]], indirect=True) async def test_swing_button( - hass: HomeAssistant, entity, swing, mock_bridge, mock_api, monkeypatch + hass: HomeAssistant, + entity, + swing, + mock_bridge, + mock_api, + monkeypatch: pytest.MonkeyPatch, ) -> None: """Test vertical swing on/off button.""" monkeypatch.setattr(DEVICE, "remote_id", "ELEC7022") @@ -88,7 +93,7 @@ async def test_swing_button( @pytest.mark.parametrize("mock_bridge", [[DEVICE]], indirect=True) async def test_control_device_fail( - hass: HomeAssistant, mock_bridge, mock_api, monkeypatch + hass: HomeAssistant, mock_bridge, mock_api, monkeypatch: pytest.MonkeyPatch ) -> None: """Test control device fail.""" await init_integration(hass) diff --git a/tests/components/switcher_kis/test_climate.py b/tests/components/switcher_kis/test_climate.py index 759f7f1bd98..5da9684bf2a 100644 --- a/tests/components/switcher_kis/test_climate.py +++ b/tests/components/switcher_kis/test_climate.py @@ -37,7 +37,7 @@ ENTITY_ID = f"{CLIMATE_DOMAIN}.{slugify(DEVICE.name)}" @pytest.mark.parametrize("mock_bridge", [[DEVICE]], indirect=True) async def test_climate_hvac_mode( - hass: HomeAssistant, mock_bridge, mock_api, monkeypatch + hass: HomeAssistant, mock_bridge, mock_api, monkeypatch: pytest.MonkeyPatch ) -> None: """Test climate hvac mode service.""" await init_integration(hass) @@ -92,7 +92,7 @@ async def test_climate_hvac_mode( @pytest.mark.parametrize("mock_bridge", [[DEVICE]], indirect=True) async def test_climate_temperature( - hass: HomeAssistant, mock_bridge, mock_api, monkeypatch + hass: HomeAssistant, mock_bridge, mock_api, monkeypatch: pytest.MonkeyPatch ) -> None: """Test climate temperature service.""" await init_integration(hass) @@ -144,7 +144,7 @@ async def test_climate_temperature( @pytest.mark.parametrize("mock_bridge", [[DEVICE]], indirect=True) async def test_climate_fan_level( - hass: HomeAssistant, mock_bridge, mock_api, monkeypatch + hass: HomeAssistant, mock_bridge, mock_api, monkeypatch: pytest.MonkeyPatch ) -> None: """Test climate fan level service.""" await init_integration(hass) @@ -179,7 +179,7 @@ async def test_climate_fan_level( @pytest.mark.parametrize("mock_bridge", [[DEVICE]], indirect=True) async def test_climate_swing( - hass: HomeAssistant, mock_bridge, mock_api, monkeypatch + hass: HomeAssistant, mock_bridge, mock_api, monkeypatch: pytest.MonkeyPatch ) -> None: """Test climate swing service.""" await init_integration(hass) @@ -234,9 +234,7 @@ async def test_climate_swing( @pytest.mark.parametrize("mock_bridge", [[DEVICE]], indirect=True) -async def test_control_device_fail( - hass: HomeAssistant, mock_bridge, mock_api, monkeypatch -) -> None: +async def test_control_device_fail(hass: HomeAssistant, mock_bridge, mock_api) -> None: """Test control device fail.""" await init_integration(hass) assert mock_bridge @@ -295,7 +293,7 @@ async def test_control_device_fail( @pytest.mark.parametrize("mock_bridge", [[DEVICE]], indirect=True) async def test_bad_update_discard( - hass: HomeAssistant, mock_bridge, mock_api, monkeypatch + hass: HomeAssistant, mock_bridge, mock_api, monkeypatch: pytest.MonkeyPatch ) -> None: """Test that a bad update from device is discarded.""" await init_integration(hass) @@ -318,7 +316,7 @@ async def test_bad_update_discard( @pytest.mark.parametrize("mock_bridge", [[DEVICE]], indirect=True) async def test_climate_control_errors( - hass: HomeAssistant, mock_bridge, mock_api, monkeypatch + hass: HomeAssistant, mock_bridge, mock_api, monkeypatch: pytest.MonkeyPatch ) -> None: """Test control with settings not supported by device.""" await init_integration(hass) diff --git a/tests/components/switcher_kis/test_cover.py b/tests/components/switcher_kis/test_cover.py index 07f349d1a72..57e2f98915e 100644 --- a/tests/components/switcher_kis/test_cover.py +++ b/tests/components/switcher_kis/test_cover.py @@ -31,7 +31,9 @@ ENTITY_ID = f"{COVER_DOMAIN}.{slugify(DEVICE.name)}" @pytest.mark.parametrize("mock_bridge", [[DEVICE]], indirect=True) -async def test_cover(hass: HomeAssistant, mock_bridge, mock_api, monkeypatch) -> None: +async def test_cover( + hass: HomeAssistant, mock_bridge, mock_api, monkeypatch: pytest.MonkeyPatch +) -> None: """Test cover services.""" await init_integration(hass) assert mock_bridge diff --git a/tests/components/switcher_kis/test_diagnostics.py b/tests/components/switcher_kis/test_diagnostics.py index f49ab99ba6c..107a48a1062 100644 --- a/tests/components/switcher_kis/test_diagnostics.py +++ b/tests/components/switcher_kis/test_diagnostics.py @@ -1,5 +1,7 @@ """Tests for the diagnostics data provided by Switcher.""" +import pytest + from homeassistant.components.diagnostics import REDACTED from homeassistant.core import HomeAssistant @@ -11,7 +13,10 @@ from tests.typing import ClientSessionGenerator async def test_diagnostics( - hass: HomeAssistant, hass_client: ClientSessionGenerator, mock_bridge, monkeypatch + hass: HomeAssistant, + hass_client: ClientSessionGenerator, + mock_bridge, + monkeypatch: pytest.MonkeyPatch, ) -> None: """Test diagnostics.""" entry = await init_integration(hass) diff --git a/tests/components/switcher_kis/test_sensor.py b/tests/components/switcher_kis/test_sensor.py index 1be2efed987..8ccc33f2d37 100644 --- a/tests/components/switcher_kis/test_sensor.py +++ b/tests/components/switcher_kis/test_sensor.py @@ -74,7 +74,9 @@ async def test_sensor_disabled( @pytest.mark.parametrize("mock_bridge", [[DUMMY_WATER_HEATER_DEVICE]], indirect=True) -async def test_sensor_update(hass: HomeAssistant, mock_bridge, monkeypatch) -> None: +async def test_sensor_update( + hass: HomeAssistant, mock_bridge, monkeypatch: pytest.MonkeyPatch +) -> None: """Test sensor update.""" await init_integration(hass) assert mock_bridge diff --git a/tests/components/switcher_kis/test_services.py b/tests/components/switcher_kis/test_services.py index 039daec4c97..26c54ee53ed 100644 --- a/tests/components/switcher_kis/test_services.py +++ b/tests/components/switcher_kis/test_services.py @@ -30,7 +30,7 @@ from .consts import ( @pytest.mark.parametrize("mock_bridge", [[DUMMY_WATER_HEATER_DEVICE]], indirect=True) async def test_turn_on_with_timer_service( - hass: HomeAssistant, mock_bridge, mock_api, monkeypatch + hass: HomeAssistant, mock_bridge, mock_api, monkeypatch: pytest.MonkeyPatch ) -> None: """Test the turn on with timer service.""" await init_integration(hass) diff --git a/tests/components/switcher_kis/test_switch.py b/tests/components/switcher_kis/test_switch.py index 058546ac2ae..f14a8f5b1ca 100644 --- a/tests/components/switcher_kis/test_switch.py +++ b/tests/components/switcher_kis/test_switch.py @@ -23,7 +23,9 @@ from .consts import DUMMY_PLUG_DEVICE, DUMMY_WATER_HEATER_DEVICE @pytest.mark.parametrize("mock_bridge", [[DUMMY_WATER_HEATER_DEVICE]], indirect=True) -async def test_switch(hass: HomeAssistant, mock_bridge, mock_api, monkeypatch) -> None: +async def test_switch( + hass: HomeAssistant, mock_bridge, mock_api, monkeypatch: pytest.MonkeyPatch +) -> None: """Test the switch.""" await init_integration(hass) assert mock_bridge @@ -75,7 +77,7 @@ async def test_switch_control_fail( hass: HomeAssistant, mock_bridge, mock_api, - monkeypatch, + monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture, ) -> None: """Test switch control fail."""