From 470ef554d788bea1328fa950ddf7e6e21e301149 Mon Sep 17 00:00:00 2001 From: Sid <27780930+autinerd@users.noreply.github.com> Date: Sat, 16 Mar 2024 11:03:25 +0100 Subject: [PATCH] Fix freedompro tests for ruff B018 (#113583) --- .../freedompro/test_binary_sensor.py | 5 ++-- tests/components/freedompro/test_climate.py | 24 ++++++++++------- tests/components/freedompro/test_cover.py | 14 ++++------ tests/components/freedompro/test_fan.py | 20 +++++++------- tests/components/freedompro/test_init.py | 8 ++++-- tests/components/freedompro/test_light.py | 27 ++++++++++++------- tests/components/freedompro/test_lock.py | 15 ++++++----- tests/components/freedompro/test_sensor.py | 5 ++-- tests/components/freedompro/test_switch.py | 17 +++++++----- 9 files changed, 75 insertions(+), 60 deletions(-) diff --git a/tests/components/freedompro/test_binary_sensor.py b/tests/components/freedompro/test_binary_sensor.py index 30bb1a58117..f3bfeb68c6c 100644 --- a/tests/components/freedompro/test_binary_sensor.py +++ b/tests/components/freedompro/test_binary_sensor.py @@ -12,7 +12,7 @@ from homeassistant.util.dt import utcnow from .conftest import get_states_response_for_uid -from tests.common import async_fire_time_changed +from tests.common import MockConfigEntry, async_fire_time_changed @pytest.mark.parametrize( @@ -48,14 +48,13 @@ async def test_binary_sensor_get_state( hass: HomeAssistant, entity_registry: er.EntityRegistry, device_registry: dr.DeviceRegistry, - init_integration, + init_integration: MockConfigEntry, entity_id: str, uid: str, name: str, model: str, ) -> None: """Test states of the binary_sensor.""" - init_integration device = device_registry.async_get_device(identifiers={("freedompro", uid)}) assert device is not None diff --git a/tests/components/freedompro/test_climate.py b/tests/components/freedompro/test_climate.py index 0195f6bde94..9a8f0c5030c 100644 --- a/tests/components/freedompro/test_climate.py +++ b/tests/components/freedompro/test_climate.py @@ -24,7 +24,7 @@ from homeassistant.util.dt import utcnow from .conftest import get_states_response_for_uid -from tests.common import async_fire_time_changed +from tests.common import MockConfigEntry, async_fire_time_changed uid = "3WRRJR6RCZQZSND8VP0YTO3YXCSOFPKBMW8T51TU-LQ*TWMYQKL3UVED4HSIIB9GXJWJZBQCXG-9VE-N2IUAIWI" @@ -33,7 +33,7 @@ async def test_climate_get_state( hass: HomeAssistant, entity_registry: er.EntityRegistry, device_registry: dr.DeviceRegistry, - init_integration, + init_integration: MockConfigEntry, ) -> None: """Test states of the climate.""" device = device_registry.async_get_device(identifiers={("freedompro", uid)}) @@ -88,10 +88,11 @@ async def test_climate_get_state( async def test_climate_set_off( - hass: HomeAssistant, entity_registry: er.EntityRegistry, init_integration + hass: HomeAssistant, + entity_registry: er.EntityRegistry, + init_integration: MockConfigEntry, ) -> None: """Test set off climate.""" - init_integration entity_id = "climate.thermostat" state = hass.states.get(entity_id) @@ -119,10 +120,11 @@ async def test_climate_set_off( async def test_climate_set_unsupported_hvac_mode( - hass: HomeAssistant, entity_registry: er.EntityRegistry, init_integration + hass: HomeAssistant, + entity_registry: er.EntityRegistry, + init_integration: MockConfigEntry, ) -> None: """Test set unsupported hvac mode climate.""" - init_integration entity_id = "climate.thermostat" state = hass.states.get(entity_id) @@ -143,10 +145,11 @@ async def test_climate_set_unsupported_hvac_mode( async def test_climate_set_temperature( - hass: HomeAssistant, entity_registry: er.EntityRegistry, init_integration + hass: HomeAssistant, + entity_registry: er.EntityRegistry, + init_integration: MockConfigEntry, ) -> None: """Test set temperature climate.""" - init_integration entity_id = "climate.thermostat" state = hass.states.get(entity_id) @@ -189,10 +192,11 @@ async def test_climate_set_temperature( async def test_climate_set_temperature_unsupported_hvac_mode( - hass: HomeAssistant, entity_registry: er.EntityRegistry, init_integration + hass: HomeAssistant, + entity_registry: er.EntityRegistry, + init_integration: MockConfigEntry, ) -> None: """Test set temperature climate unsupported hvac mode.""" - init_integration entity_id = "climate.thermostat" state = hass.states.get(entity_id) diff --git a/tests/components/freedompro/test_cover.py b/tests/components/freedompro/test_cover.py index 9eef2b0b95b..ba48da1d1d4 100644 --- a/tests/components/freedompro/test_cover.py +++ b/tests/components/freedompro/test_cover.py @@ -21,7 +21,7 @@ from homeassistant.util.dt import utcnow from .conftest import get_states_response_for_uid -from tests.common import async_fire_time_changed +from tests.common import MockConfigEntry, async_fire_time_changed @pytest.mark.parametrize( @@ -39,14 +39,13 @@ async def test_cover_get_state( hass: HomeAssistant, entity_registry: er.EntityRegistry, device_registry: dr.DeviceRegistry, - init_integration, + init_integration: MockConfigEntry, entity_id: str, uid: str, name: str, model: str, ) -> None: """Test states of the cover.""" - init_integration device = device_registry.async_get_device(identifiers={("freedompro", uid)}) assert device is not None @@ -98,14 +97,13 @@ async def test_cover_get_state( async def test_cover_set_position( hass: HomeAssistant, entity_registry: er.EntityRegistry, - init_integration, + init_integration: MockConfigEntry, entity_id: str, uid: str, name: str, model: str, ) -> None: """Test set position of the cover.""" - init_integration state = hass.states.get(entity_id) assert state @@ -153,14 +151,13 @@ async def test_cover_set_position( async def test_cover_close( hass: HomeAssistant, entity_registry: er.EntityRegistry, - init_integration, + init_integration: MockConfigEntry, entity_id: str, uid: str, name: str, model: str, ) -> None: """Test close cover.""" - init_integration states_response = get_states_response_for_uid(uid) states_response[0]["state"]["position"] = 100 @@ -216,14 +213,13 @@ async def test_cover_close( async def test_cover_open( hass: HomeAssistant, entity_registry: er.EntityRegistry, - init_integration, + init_integration: MockConfigEntry, entity_id: str, uid: str, name: str, model: str, ) -> None: """Test open cover.""" - init_integration state = hass.states.get(entity_id) assert state diff --git a/tests/components/freedompro/test_fan.py b/tests/components/freedompro/test_fan.py index ea9b94ffc41..fd1a7fb4399 100644 --- a/tests/components/freedompro/test_fan.py +++ b/tests/components/freedompro/test_fan.py @@ -17,7 +17,7 @@ from homeassistant.util.dt import utcnow from .conftest import get_states_response_for_uid -from tests.common import async_fire_time_changed +from tests.common import MockConfigEntry, async_fire_time_changed uid = "3WRRJR6RCZQZSND8VP0YTO3YXCSOFPKBMW8T51TU-LQ*ILYH1E3DWZOVMNEUIMDYMNLOW-LFRQFDPWWJOVHVDOS" @@ -26,10 +26,9 @@ async def test_fan_get_state( hass: HomeAssistant, entity_registry: er.EntityRegistry, device_registry: dr.DeviceRegistry, - init_integration, + init_integration: MockConfigEntry, ) -> None: """Test states of the fan.""" - init_integration device = device_registry.async_get_device(identifiers={("freedompro", uid)}) assert device is not None @@ -72,10 +71,11 @@ async def test_fan_get_state( async def test_fan_set_off( - hass: HomeAssistant, entity_registry: er.EntityRegistry, init_integration + hass: HomeAssistant, + entity_registry: er.EntityRegistry, + init_integration: MockConfigEntry, ) -> None: """Test turn off the fan.""" - init_integration entity_id = "fan.bedroom" @@ -126,10 +126,11 @@ async def test_fan_set_off( async def test_fan_set_on( - hass: HomeAssistant, entity_registry: er.EntityRegistry, init_integration + hass: HomeAssistant, + entity_registry: er.EntityRegistry, + init_integration: MockConfigEntry, ) -> None: """Test turn on the fan.""" - init_integration entity_id = "fan.bedroom" state = hass.states.get(entity_id) @@ -167,10 +168,11 @@ async def test_fan_set_on( async def test_fan_set_percent( - hass: HomeAssistant, entity_registry: er.EntityRegistry, init_integration + hass: HomeAssistant, + entity_registry: er.EntityRegistry, + init_integration: MockConfigEntry, ) -> None: """Test turn on the fan.""" - init_integration entity_id = "fan.bedroom" state = hass.states.get(entity_id) diff --git a/tests/components/freedompro/test_init.py b/tests/components/freedompro/test_init.py index 18bf6d41ae2..58f9c493582 100644 --- a/tests/components/freedompro/test_init.py +++ b/tests/components/freedompro/test_init.py @@ -14,7 +14,9 @@ LOGGER = logging.getLogger(__name__) ENTITY_ID = f"{DOMAIN}.fake_name" -async def test_async_setup_entry(hass: HomeAssistant, init_integration) -> None: +async def test_async_setup_entry( + hass: HomeAssistant, init_integration: MockConfigEntry +) -> None: """Test a successful setup entry.""" entry = init_integration assert entry is not None @@ -44,7 +46,9 @@ async def test_config_not_ready(hass: HomeAssistant) -> None: assert entry.state == ConfigEntryState.SETUP_RETRY -async def test_unload_entry(hass: HomeAssistant, init_integration) -> None: +async def test_unload_entry( + hass: HomeAssistant, init_integration: MockConfigEntry +) -> None: """Test successful unload of entry.""" entry = init_integration diff --git a/tests/components/freedompro/test_light.py b/tests/components/freedompro/test_light.py index d0270f40843..05439adf764 100644 --- a/tests/components/freedompro/test_light.py +++ b/tests/components/freedompro/test_light.py @@ -14,6 +14,8 @@ from homeassistant.const import ATTR_ENTITY_ID, SERVICE_TURN_OFF, STATE_OFF, STA from homeassistant.core import HomeAssistant from homeassistant.helpers import entity_registry as er +from tests.common import MockConfigEntry + @pytest.fixture(autouse=True) def mock_freedompro_put_state(): @@ -23,10 +25,11 @@ def mock_freedompro_put_state(): async def test_light_get_state( - hass: HomeAssistant, entity_registry: er.EntityRegistry, init_integration + hass: HomeAssistant, + entity_registry: er.EntityRegistry, + init_integration: MockConfigEntry, ) -> None: """Test states of the light.""" - init_integration entity_id = "light.lightbulb" state = hass.states.get(entity_id) @@ -43,10 +46,11 @@ async def test_light_get_state( async def test_light_set_on( - hass: HomeAssistant, entity_registry: er.EntityRegistry, init_integration + hass: HomeAssistant, + entity_registry: er.EntityRegistry, + init_integration: MockConfigEntry, ) -> None: """Test set on of the light.""" - init_integration entity_id = "light.lightbulb" state = hass.states.get(entity_id) @@ -74,10 +78,11 @@ async def test_light_set_on( async def test_light_set_off( - hass: HomeAssistant, entity_registry: er.EntityRegistry, init_integration + hass: HomeAssistant, + entity_registry: er.EntityRegistry, + init_integration: MockConfigEntry, ) -> None: """Test set off of the light.""" - init_integration entity_id = "light.bedroomlight" state = hass.states.get(entity_id) @@ -105,10 +110,11 @@ async def test_light_set_off( async def test_light_set_brightness( - hass: HomeAssistant, entity_registry: er.EntityRegistry, init_integration + hass: HomeAssistant, + entity_registry: er.EntityRegistry, + init_integration: MockConfigEntry, ) -> None: """Test set brightness of the light.""" - init_integration entity_id = "light.lightbulb" state = hass.states.get(entity_id) @@ -137,10 +143,11 @@ async def test_light_set_brightness( async def test_light_set_hue( - hass: HomeAssistant, entity_registry: er.EntityRegistry, init_integration + hass: HomeAssistant, + entity_registry: er.EntityRegistry, + init_integration: MockConfigEntry, ) -> None: """Test set brightness of the light.""" - init_integration entity_id = "light.lightbulb" state = hass.states.get(entity_id) diff --git a/tests/components/freedompro/test_lock.py b/tests/components/freedompro/test_lock.py index ad5b53dd51d..94f5609ee47 100644 --- a/tests/components/freedompro/test_lock.py +++ b/tests/components/freedompro/test_lock.py @@ -16,7 +16,7 @@ from homeassistant.util.dt import utcnow from .conftest import get_states_response_for_uid -from tests.common import async_fire_time_changed +from tests.common import MockConfigEntry, async_fire_time_changed uid = "2WRRJR6RCZQZSND8VP0YTO3YXCSOFPKBMW8T51TU-LQ*2VAS3HTWINNZ5N6HVEIPDJ6NX85P2-AM-GSYWUCNPU0" @@ -25,10 +25,9 @@ async def test_lock_get_state( hass: HomeAssistant, entity_registry: er.EntityRegistry, device_registry: dr.DeviceRegistry, - init_integration, + init_integration: MockConfigEntry, ) -> None: """Test states of the lock.""" - init_integration device = device_registry.async_get_device(identifiers={("freedompro", uid)}) assert device is not None @@ -68,10 +67,11 @@ async def test_lock_get_state( async def test_lock_set_unlock( - hass: HomeAssistant, entity_registry: er.EntityRegistry, init_integration + hass: HomeAssistant, + entity_registry: er.EntityRegistry, + init_integration: MockConfigEntry, ) -> None: """Test set on of the lock.""" - init_integration entity_id = "lock.lock" @@ -117,10 +117,11 @@ async def test_lock_set_unlock( async def test_lock_set_lock( - hass: HomeAssistant, entity_registry: er.EntityRegistry, init_integration + hass: HomeAssistant, + entity_registry: er.EntityRegistry, + init_integration: MockConfigEntry, ) -> None: """Test set on of the lock.""" - init_integration entity_id = "lock.lock" state = hass.states.get(entity_id) diff --git a/tests/components/freedompro/test_sensor.py b/tests/components/freedompro/test_sensor.py index 1deb895ad3d..c9075299238 100644 --- a/tests/components/freedompro/test_sensor.py +++ b/tests/components/freedompro/test_sensor.py @@ -11,7 +11,7 @@ from homeassistant.util.dt import utcnow from .conftest import get_states_response_for_uid -from tests.common import async_fire_time_changed +from tests.common import MockConfigEntry, async_fire_time_changed @pytest.mark.parametrize( @@ -37,13 +37,12 @@ from tests.common import async_fire_time_changed async def test_sensor_get_state( hass: HomeAssistant, entity_registry: er.EntityRegistry, - init_integration, + init_integration: MockConfigEntry, entity_id: str, uid: str, name: str, ) -> None: """Test states of the sensor.""" - init_integration state = hass.states.get(entity_id) assert state diff --git a/tests/components/freedompro/test_switch.py b/tests/components/freedompro/test_switch.py index e3ab02de55b..831218550a4 100644 --- a/tests/components/freedompro/test_switch.py +++ b/tests/components/freedompro/test_switch.py @@ -12,16 +12,17 @@ from homeassistant.util.dt import utcnow from .conftest import get_states_response_for_uid -from tests.common import async_fire_time_changed +from tests.common import MockConfigEntry, async_fire_time_changed uid = "3WRRJR6RCZQZSND8VP0YTO3YXCSOFPKBMW8T51TU-LQ*1JKU1MVWHQL-Z9SCUS85VFXMRGNDCDNDDUVVDKBU31W" async def test_switch_get_state( - hass: HomeAssistant, entity_registry: er.EntityRegistry, init_integration + hass: HomeAssistant, + entity_registry: er.EntityRegistry, + init_integration: MockConfigEntry, ) -> None: """Test states of the switch.""" - init_integration entity_id = "switch.irrigation_switch" state = hass.states.get(entity_id) @@ -54,10 +55,11 @@ async def test_switch_get_state( async def test_switch_set_off( - hass: HomeAssistant, entity_registry: er.EntityRegistry, init_integration + hass: HomeAssistant, + entity_registry: er.EntityRegistry, + init_integration: MockConfigEntry, ) -> None: """Test set off of the switch.""" - init_integration entity_id = "switch.irrigation_switch" @@ -105,10 +107,11 @@ async def test_switch_set_off( async def test_switch_set_on( - hass: HomeAssistant, entity_registry: er.EntityRegistry, init_integration + hass: HomeAssistant, + entity_registry: er.EntityRegistry, + init_integration: MockConfigEntry, ) -> None: """Test set on of the switch.""" - init_integration entity_id = "switch.irrigation_switch" state = hass.states.get(entity_id)