Fix freedompro tests for ruff B018 (#113583)

This commit is contained in:
Sid 2024-03-16 11:03:25 +01:00 committed by GitHub
parent dd3101e161
commit 470ef554d7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 75 additions and 60 deletions

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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)

View file

@ -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)

View file

@ -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

View file

@ -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)