Improve type hints in flo tests (#120730)

pull/120750/head
epenet 2024-06-28 13:34:26 +02:00 committed by GitHub
parent 2e031d0194
commit d0ce0d562e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 39 additions and 19 deletions

View File

@ -16,7 +16,7 @@ from tests.test_util.aiohttp import AiohttpClientMocker
@pytest.fixture
def config_entry(hass):
def config_entry() -> MockConfigEntry:
"""Config entry version 1 fixture."""
return MockConfigEntry(
domain=FLO_DOMAIN,

View File

@ -1,5 +1,7 @@
"""Test Flo by Moen binary sensor entities."""
import pytest
from homeassistant.components.flo.const import DOMAIN as FLO_DOMAIN
from homeassistant.const import (
ATTR_FRIENDLY_NAME,
@ -13,9 +15,12 @@ from homeassistant.setup import async_setup_component
from .common import TEST_PASSWORD, TEST_USER_ID
from tests.common import MockConfigEntry
@pytest.mark.usefixtures("aioclient_mock_fixture")
async def test_binary_sensors(
hass: HomeAssistant, config_entry, aioclient_mock_fixture
hass: HomeAssistant, config_entry: MockConfigEntry
) -> None:
"""Test Flo by Moen sensors."""
config_entry.add_to_hass(hass)

View File

@ -5,6 +5,8 @@ import json
import time
from unittest.mock import patch
import pytest
from homeassistant import config_entries
from homeassistant.components.flo.const import DOMAIN
from homeassistant.const import CONTENT_TYPE_JSON
@ -16,7 +18,8 @@ from .common import TEST_EMAIL_ADDRESS, TEST_PASSWORD, TEST_TOKEN, TEST_USER_ID
from tests.test_util.aiohttp import AiohttpClientMocker
async def test_form(hass: HomeAssistant, aioclient_mock_fixture) -> None:
@pytest.mark.usefixtures("aioclient_mock_fixture")
async def test_form(hass: HomeAssistant) -> None:
"""Test we get the form."""
result = await hass.config_entries.flow.async_init(

View File

@ -5,6 +5,7 @@ from unittest.mock import patch
from aioflo.errors import RequestError
from freezegun.api import FrozenDateTimeFactory
import pytest
from homeassistant.components.flo.const import DOMAIN as FLO_DOMAIN
from homeassistant.components.flo.coordinator import FloDeviceDataUpdateCoordinator
@ -14,14 +15,14 @@ from homeassistant.setup import async_setup_component
from .common import TEST_PASSWORD, TEST_USER_ID
from tests.common import async_fire_time_changed
from tests.common import MockConfigEntry, async_fire_time_changed
from tests.test_util.aiohttp import AiohttpClientMocker
@pytest.mark.usefixtures("aioclient_mock_fixture")
async def test_device(
hass: HomeAssistant,
config_entry,
aioclient_mock_fixture,
config_entry: MockConfigEntry,
aioclient_mock: AiohttpClientMocker,
freezer: FrozenDateTimeFactory,
) -> None:
@ -90,10 +91,10 @@ async def test_device(
assert aioclient_mock.call_count == call_count + 6
@pytest.mark.usefixtures("aioclient_mock_fixture")
async def test_device_failures(
hass: HomeAssistant,
config_entry,
aioclient_mock_fixture,
config_entry: MockConfigEntry,
aioclient_mock: AiohttpClientMocker,
freezer: FrozenDateTimeFactory,
) -> None:

View File

@ -1,5 +1,7 @@
"""Test init."""
import pytest
from homeassistant.components.flo.const import DOMAIN as FLO_DOMAIN
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import HomeAssistant
@ -7,10 +9,11 @@ from homeassistant.setup import async_setup_component
from .common import TEST_PASSWORD, TEST_USER_ID
from tests.common import MockConfigEntry
async def test_setup_entry(
hass: HomeAssistant, config_entry, aioclient_mock_fixture
) -> None:
@pytest.mark.usefixtures("aioclient_mock_fixture")
async def test_setup_entry(hass: HomeAssistant, config_entry: MockConfigEntry) -> None:
"""Test migration of config entry from v1."""
config_entry.add_to_hass(hass)
assert await async_setup_component(

View File

@ -1,5 +1,7 @@
"""Test Flo by Moen sensor entities."""
import pytest
from homeassistant.components.flo.const import DOMAIN as FLO_DOMAIN
from homeassistant.components.sensor import ATTR_STATE_CLASS, SensorStateClass
from homeassistant.const import ATTR_ENTITY_ID, CONF_PASSWORD, CONF_USERNAME
@ -9,12 +11,12 @@ from homeassistant.util.unit_system import US_CUSTOMARY_SYSTEM
from .common import TEST_PASSWORD, TEST_USER_ID
from tests.common import MockConfigEntry
from tests.test_util.aiohttp import AiohttpClientMocker
async def test_sensors(
hass: HomeAssistant, config_entry, aioclient_mock_fixture
) -> None:
@pytest.mark.usefixtures("aioclient_mock_fixture")
async def test_sensors(hass: HomeAssistant, config_entry: MockConfigEntry) -> None:
"""Test Flo by Moen sensors."""
hass.config.units = US_CUSTOMARY_SYSTEM
config_entry.add_to_hass(hass)
@ -85,10 +87,10 @@ async def test_sensors(
)
@pytest.mark.usefixtures("aioclient_mock_fixture")
async def test_manual_update_entity(
hass: HomeAssistant,
config_entry,
aioclient_mock_fixture,
config_entry: MockConfigEntry,
aioclient_mock: AiohttpClientMocker,
) -> None:
"""Test manual update entity via service homeasasistant/update_entity."""

View File

@ -19,15 +19,16 @@ from homeassistant.setup import async_setup_component
from .common import TEST_PASSWORD, TEST_USER_ID
from tests.common import MockConfigEntry
from tests.test_util.aiohttp import AiohttpClientMocker
SWITCH_ENTITY_ID = "switch.smart_water_shutoff_shutoff_valve"
@pytest.mark.usefixtures("aioclient_mock_fixture")
async def test_services(
hass: HomeAssistant,
config_entry,
aioclient_mock_fixture,
config_entry: MockConfigEntry,
aioclient_mock: AiohttpClientMocker,
) -> None:
"""Test Flo services."""

View File

@ -1,5 +1,7 @@
"""Tests for the switch domain for Flo by Moen."""
import pytest
from homeassistant.components.flo.const import DOMAIN as FLO_DOMAIN
from homeassistant.components.switch import DOMAIN
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, STATE_OFF, STATE_ON
@ -8,9 +10,12 @@ from homeassistant.setup import async_setup_component
from .common import TEST_PASSWORD, TEST_USER_ID
from tests.common import MockConfigEntry
@pytest.mark.usefixtures("aioclient_mock_fixture")
async def test_valve_switches(
hass: HomeAssistant, config_entry, aioclient_mock_fixture
hass: HomeAssistant, config_entry: MockConfigEntry
) -> None:
"""Test Flo by Moen valve switches."""
config_entry.add_to_hass(hass)