Skip to content

Commit

Permalink
Fix freedompro tests for ruff B018 (home-assistant#113583)
Browse files Browse the repository at this point in the history
  • Loading branch information
autinerd authored Mar 16, 2024
1 parent dd3101e commit 470ef55
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 60 deletions.
5 changes: 2 additions & 3 deletions tests/components/freedompro/test_binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

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(
Expand Down Expand Up @@ -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
Expand Down
24 changes: 14 additions & 10 deletions tests/components/freedompro/test_climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

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"

Expand All @@ -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)})
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
14 changes: 5 additions & 9 deletions tests/components/freedompro/test_cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

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(
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
20 changes: 11 additions & 9 deletions tests/components/freedompro/test_fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

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"

Expand All @@ -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
Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 6 additions & 2 deletions tests/components/freedompro/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
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
Expand Down Expand Up @@ -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

Expand Down
27 changes: 17 additions & 10 deletions tests/components/freedompro/test_light.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
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():
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
15 changes: 8 additions & 7 deletions tests/components/freedompro/test_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

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"

Expand All @@ -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
Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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)
Expand Down
Loading

0 comments on commit 470ef55

Please sign in to comment.