Adjust pylint plugin for components fixtures (#90217)
* Adjust pylint plugin for components fixtures * Adjust components * Use MagicMock * Adjust * Use None
This commit is contained in:
parent
e0ec3488d3
commit
69a46d4002
21 changed files with 59 additions and 59 deletions
|
@ -104,6 +104,7 @@ _TEST_FIXTURES: dict[str, list[str] | str] = {
|
|||
"enable_statistics": "bool",
|
||||
"enable_schema_validation": "bool",
|
||||
"entity_registry": "EntityRegistry",
|
||||
"entity_registry_enabled_by_default": "None",
|
||||
"freezer": "FrozenDateTimeFactory",
|
||||
"hass_access_token": "str",
|
||||
"hass_admin_credential": "Credentials",
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
"""The sensor tests for the Airzone platform."""
|
||||
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .util import async_init_integration
|
||||
|
||||
|
||||
async def test_airzone_create_sensors(
|
||||
hass: HomeAssistant, entity_registry_enabled_by_default: AsyncMock
|
||||
hass: HomeAssistant, entity_registry_enabled_by_default: None
|
||||
) -> None:
|
||||
"""Test creation of sensors."""
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
"""Fixtures for component testing."""
|
||||
from collections.abc import Generator
|
||||
from unittest.mock import AsyncMock, patch
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture(scope="session", autouse=True)
|
||||
def patch_zeroconf_multiple_catcher():
|
||||
def patch_zeroconf_multiple_catcher() -> Generator[None, None, None]:
|
||||
"""Patch zeroconf wrapper that detects if multiple instances are used."""
|
||||
with patch(
|
||||
"homeassistant.components.zeroconf.install_multiple_zeroconf_catcher",
|
||||
|
@ -16,7 +16,7 @@ def patch_zeroconf_multiple_catcher():
|
|||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def prevent_io():
|
||||
def prevent_io() -> Generator[None, None, None]:
|
||||
"""Fixture to prevent certain I/O from happening."""
|
||||
with patch(
|
||||
"homeassistant.components.http.ban.load_yaml_config_file",
|
||||
|
@ -25,10 +25,10 @@ def prevent_io():
|
|||
|
||||
|
||||
@pytest.fixture
|
||||
def entity_registry_enabled_by_default() -> Generator[AsyncMock, None, None]:
|
||||
def entity_registry_enabled_by_default() -> Generator[None, None, None]:
|
||||
"""Test fixture that ensures all entities are enabled in the registry."""
|
||||
with patch(
|
||||
"homeassistant.helpers.entity.Entity.entity_registry_enabled_default",
|
||||
return_value=True,
|
||||
) as mock_entity_registry_enabled_by_default:
|
||||
yield mock_entity_registry_enabled_by_default
|
||||
):
|
||||
yield
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
"""Sensor tests for the Goalzero integration."""
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
from homeassistant.components.goalzero.const import DEFAULT_NAME
|
||||
from homeassistant.components.sensor import (
|
||||
|
@ -29,7 +28,7 @@ from tests.test_util.aiohttp import AiohttpClientMocker
|
|||
async def test_sensors(
|
||||
hass: HomeAssistant,
|
||||
aioclient_mock: AiohttpClientMocker,
|
||||
entity_registry_enabled_by_default: AsyncMock,
|
||||
entity_registry_enabled_by_default: None,
|
||||
) -> None:
|
||||
"""Test we get sensor data."""
|
||||
await async_init_integration(hass, aioclient_mock)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
"""Tests for gree component."""
|
||||
|
||||
from greeclimate.exceptions import DeviceTimeoutError
|
||||
import pytest
|
||||
|
||||
|
@ -54,7 +55,7 @@ async def test_health_mode_disabled_by_default(hass):
|
|||
],
|
||||
)
|
||||
async def test_send_switch_on(
|
||||
hass: HomeAssistant, entity, entity_registry_enabled_by_default
|
||||
hass: HomeAssistant, entity, entity_registry_enabled_by_default: None
|
||||
) -> None:
|
||||
"""Test for sending power on command to the device."""
|
||||
await async_setup_gree(hass)
|
||||
|
@ -82,7 +83,7 @@ async def test_send_switch_on(
|
|||
],
|
||||
)
|
||||
async def test_send_switch_on_device_timeout(
|
||||
hass: HomeAssistant, device, entity, entity_registry_enabled_by_default
|
||||
hass: HomeAssistant, device, entity, entity_registry_enabled_by_default: None
|
||||
) -> None:
|
||||
"""Test for sending power on command to the device with a device timeout."""
|
||||
device().push_state_update.side_effect = DeviceTimeoutError
|
||||
|
@ -112,7 +113,7 @@ async def test_send_switch_on_device_timeout(
|
|||
],
|
||||
)
|
||||
async def test_send_switch_off(
|
||||
hass: HomeAssistant, entity, entity_registry_enabled_by_default
|
||||
hass: HomeAssistant, entity, entity_registry_enabled_by_default: None
|
||||
) -> None:
|
||||
"""Test for sending power on command to the device."""
|
||||
await async_setup_gree(hass)
|
||||
|
@ -140,7 +141,7 @@ async def test_send_switch_off(
|
|||
],
|
||||
)
|
||||
async def test_send_switch_toggle(
|
||||
hass: HomeAssistant, entity, entity_registry_enabled_by_default
|
||||
hass: HomeAssistant, entity, entity_registry_enabled_by_default: None
|
||||
) -> None:
|
||||
"""Test for sending power on command to the device."""
|
||||
await async_setup_gree(hass)
|
||||
|
@ -193,7 +194,7 @@ async def test_send_switch_toggle(
|
|||
],
|
||||
)
|
||||
async def test_entity_name(
|
||||
hass: HomeAssistant, entity, name, entity_registry_enabled_by_default
|
||||
hass: HomeAssistant, entity, name, entity_registry_enabled_by_default: None
|
||||
) -> None:
|
||||
"""Test for name property."""
|
||||
await async_setup_gree(hass)
|
||||
|
|
|
@ -364,7 +364,7 @@ def test_thread_status_to_str() -> None:
|
|||
async def test_rssi_sensor(
|
||||
hass: HomeAssistant,
|
||||
utcnow,
|
||||
entity_registry_enabled_by_default,
|
||||
entity_registry_enabled_by_default: None,
|
||||
enable_bluetooth: None,
|
||||
) -> None:
|
||||
"""Test an rssi sensor."""
|
||||
|
@ -389,7 +389,7 @@ async def test_rssi_sensor(
|
|||
async def test_migrate_rssi_sensor_unique_id(
|
||||
hass: HomeAssistant,
|
||||
utcnow,
|
||||
entity_registry_enabled_by_default,
|
||||
entity_registry_enabled_by_default: None,
|
||||
enable_bluetooth: None,
|
||||
) -> None:
|
||||
"""Test an rssi sensor unique id migration."""
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
"""Test Kostal Plenticore number."""
|
||||
|
||||
from collections.abc import Generator
|
||||
from datetime import timedelta
|
||||
from unittest.mock import patch
|
||||
|
@ -90,7 +89,7 @@ async def test_setup_all_entries(
|
|||
mock_config_entry: MockConfigEntry,
|
||||
mock_plenticore_client: ApiClient,
|
||||
mock_get_setting_values: list,
|
||||
entity_registry_enabled_by_default,
|
||||
entity_registry_enabled_by_default: None,
|
||||
) -> None:
|
||||
"""Test if all available entries are setup."""
|
||||
|
||||
|
@ -109,7 +108,7 @@ async def test_setup_no_entries(
|
|||
mock_config_entry: MockConfigEntry,
|
||||
mock_plenticore_client: ApiClient,
|
||||
mock_get_setting_values: list,
|
||||
entity_registry_enabled_by_default,
|
||||
entity_registry_enabled_by_default: None,
|
||||
) -> None:
|
||||
"""Test that no entries are setup if Plenticore does not provide data."""
|
||||
|
||||
|
@ -130,7 +129,7 @@ async def test_number_has_value(
|
|||
mock_config_entry: MockConfigEntry,
|
||||
mock_plenticore_client: ApiClient,
|
||||
mock_get_setting_values: list,
|
||||
entity_registry_enabled_by_default,
|
||||
entity_registry_enabled_by_default: None,
|
||||
) -> None:
|
||||
"""Test if number has a value if data is provided on update."""
|
||||
|
||||
|
@ -155,7 +154,7 @@ async def test_number_is_unavailable(
|
|||
mock_config_entry: MockConfigEntry,
|
||||
mock_plenticore_client: ApiClient,
|
||||
mock_get_setting_values: list,
|
||||
entity_registry_enabled_by_default,
|
||||
entity_registry_enabled_by_default: None,
|
||||
) -> None:
|
||||
"""Test if number is unavailable if no data is provided on update."""
|
||||
|
||||
|
@ -176,7 +175,7 @@ async def test_set_value(
|
|||
mock_config_entry: MockConfigEntry,
|
||||
mock_plenticore_client: ApiClient,
|
||||
mock_get_setting_values: list,
|
||||
entity_registry_enabled_by_default,
|
||||
entity_registry_enabled_by_default: None,
|
||||
) -> None:
|
||||
"""Test if a new value could be set."""
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
"""Test the Litter-Robot binary sensor entity."""
|
||||
from unittest.mock import AsyncMock, MagicMock
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import pytest
|
||||
|
||||
|
@ -17,7 +17,7 @@ from .conftest import setup_integration
|
|||
async def test_binary_sensors(
|
||||
hass: HomeAssistant,
|
||||
mock_account: MagicMock,
|
||||
entity_registry_enabled_by_default: AsyncMock,
|
||||
entity_registry_enabled_by_default: None,
|
||||
) -> None:
|
||||
"""Tests binary sensors."""
|
||||
await setup_integration(hass, mock_account, PLATFORM_DOMAIN)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
"""Test the OralB sensors."""
|
||||
|
||||
from homeassistant.components.oralb.const import DOMAIN
|
||||
from homeassistant.const import ATTR_FRIENDLY_NAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -16,7 +17,9 @@ from tests.components.bluetooth import (
|
|||
)
|
||||
|
||||
|
||||
async def test_sensors(hass: HomeAssistant, entity_registry_enabled_by_default) -> None:
|
||||
async def test_sensors(
|
||||
hass: HomeAssistant, entity_registry_enabled_by_default: None
|
||||
) -> None:
|
||||
"""Test setting up creates the sensors."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
@ -47,7 +50,7 @@ async def test_sensors(hass: HomeAssistant, entity_registry_enabled_by_default)
|
|||
|
||||
|
||||
async def test_sensors_io_series_4(
|
||||
hass: HomeAssistant, entity_registry_enabled_by_default
|
||||
hass: HomeAssistant, entity_registry_enabled_by_default: None
|
||||
) -> None:
|
||||
"""Test setting up creates the sensors with an io series 4."""
|
||||
entry = MockConfigEntry(
|
||||
|
|
|
@ -20,7 +20,9 @@ from .mocks import _mock_powerwall_with_fixtures
|
|||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_sensors(hass: HomeAssistant, entity_registry_enabled_by_default) -> None:
|
||||
async def test_sensors(
|
||||
hass: HomeAssistant, entity_registry_enabled_by_default: None
|
||||
) -> None:
|
||||
"""Test creation of the sensors."""
|
||||
|
||||
mock_powerwall = await _mock_powerwall_with_fixtures(hass)
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
"""The binary sensor tests for the QNAP QSW platform."""
|
||||
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
from homeassistant.components.qnap_qsw.const import ATTR_MESSAGE
|
||||
from homeassistant.const import STATE_OFF, STATE_ON
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -12,7 +10,7 @@ from .util import async_init_integration
|
|||
|
||||
async def test_qnap_qsw_create_binary_sensors(
|
||||
hass: HomeAssistant,
|
||||
entity_registry_enabled_by_default: AsyncMock,
|
||||
entity_registry_enabled_by_default: None,
|
||||
entity_registry: er.EntityRegistry,
|
||||
) -> None:
|
||||
"""Test creation of binary sensors."""
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
"""The sensor tests for the QNAP QSW platform."""
|
||||
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
from homeassistant.components.qnap_qsw.const import ATTR_MAX
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
|
@ -10,7 +8,7 @@ from .util import async_init_integration
|
|||
|
||||
async def test_qnap_qsw_create_sensors(
|
||||
hass: HomeAssistant,
|
||||
entity_registry_enabled_by_default: AsyncMock,
|
||||
entity_registry_enabled_by_default: None,
|
||||
) -> None:
|
||||
"""Test creation of sensors."""
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
"""The tests for Radarr sensor platform."""
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
from homeassistant.components.sensor import SensorDeviceClass
|
||||
from homeassistant.const import ATTR_DEVICE_CLASS, ATTR_UNIT_OF_MEASUREMENT
|
||||
|
@ -13,7 +12,7 @@ from tests.test_util.aiohttp import AiohttpClientMocker
|
|||
async def test_sensors(
|
||||
hass: HomeAssistant,
|
||||
aioclient_mock: AiohttpClientMocker,
|
||||
entity_registry_enabled_by_default: AsyncMock,
|
||||
entity_registry_enabled_by_default: None,
|
||||
) -> None:
|
||||
"""Test for successfully setting up the Radarr platform."""
|
||||
await setup_integration(hass, aioclient_mock)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from datetime import timedelta
|
||||
from unittest.mock import AsyncMock, patch
|
||||
from unittest.mock import patch
|
||||
|
||||
from pysensibo.model import SensiboData
|
||||
import pytest
|
||||
|
@ -16,7 +16,7 @@ from tests.common import async_fire_time_changed
|
|||
|
||||
async def test_binary_sensor(
|
||||
hass: HomeAssistant,
|
||||
entity_registry_enabled_by_default: AsyncMock,
|
||||
entity_registry_enabled_by_default: None,
|
||||
load_int: ConfigEntry,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
get_data: SensiboData,
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
from unittest.mock import AsyncMock, patch
|
||||
from unittest.mock import patch
|
||||
|
||||
from pysensibo.model import SensiboData
|
||||
import pytest
|
||||
|
@ -720,7 +720,7 @@ async def test_climate_no_fan_no_swing(
|
|||
|
||||
async def test_climate_set_timer(
|
||||
hass: HomeAssistant,
|
||||
entity_registry_enabled_by_default: AsyncMock,
|
||||
entity_registry_enabled_by_default: None,
|
||||
load_int: ConfigEntry,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
get_data: SensiboData,
|
||||
|
@ -824,7 +824,7 @@ async def test_climate_set_timer(
|
|||
|
||||
async def test_climate_pure_boost(
|
||||
hass: HomeAssistant,
|
||||
entity_registry_enabled_by_default: AsyncMock,
|
||||
entity_registry_enabled_by_default: None,
|
||||
load_int: ConfigEntry,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
get_data: SensiboData,
|
||||
|
@ -928,7 +928,7 @@ async def test_climate_pure_boost(
|
|||
|
||||
async def test_climate_climate_react(
|
||||
hass: HomeAssistant,
|
||||
entity_registry_enabled_by_default: AsyncMock,
|
||||
entity_registry_enabled_by_default: None,
|
||||
load_int: ConfigEntry,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
get_data: SensiboData,
|
||||
|
@ -1091,7 +1091,7 @@ async def test_climate_climate_react(
|
|||
|
||||
async def test_climate_climate_react_fahrenheit(
|
||||
hass: HomeAssistant,
|
||||
entity_registry_enabled_by_default: AsyncMock,
|
||||
entity_registry_enabled_by_default: None,
|
||||
load_int: ConfigEntry,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
get_data: SensiboData,
|
||||
|
@ -1234,7 +1234,7 @@ async def test_climate_climate_react_fahrenheit(
|
|||
|
||||
async def test_climate_full_ac_state(
|
||||
hass: HomeAssistant,
|
||||
entity_registry_enabled_by_default: AsyncMock,
|
||||
entity_registry_enabled_by_default: None,
|
||||
load_int: ConfigEntry,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
get_data: SensiboData,
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from datetime import timedelta
|
||||
from unittest.mock import AsyncMock, patch
|
||||
from unittest.mock import patch
|
||||
|
||||
from pysensibo.model import SensiboData
|
||||
import pytest
|
||||
|
@ -23,7 +23,7 @@ from tests.common import async_fire_time_changed
|
|||
|
||||
async def test_number(
|
||||
hass: HomeAssistant,
|
||||
entity_registry_enabled_by_default: AsyncMock,
|
||||
entity_registry_enabled_by_default: None,
|
||||
load_int: ConfigEntry,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
get_data: SensiboData,
|
||||
|
@ -53,7 +53,7 @@ async def test_number(
|
|||
|
||||
async def test_number_set_value(
|
||||
hass: HomeAssistant,
|
||||
entity_registry_enabled_by_default: AsyncMock,
|
||||
entity_registry_enabled_by_default: None,
|
||||
load_int: ConfigEntry,
|
||||
get_data: SensiboData,
|
||||
) -> None:
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from datetime import timedelta
|
||||
from unittest.mock import AsyncMock, patch
|
||||
from unittest.mock import patch
|
||||
|
||||
from pysensibo.model import SensiboData
|
||||
import pytest
|
||||
|
@ -16,7 +16,7 @@ from tests.common import async_fire_time_changed
|
|||
|
||||
async def test_sensor(
|
||||
hass: HomeAssistant,
|
||||
entity_registry_enabled_by_default: AsyncMock,
|
||||
entity_registry_enabled_by_default: None,
|
||||
load_int: ConfigEntry,
|
||||
monkeypatch: pytest.pytest.MonkeyPatch,
|
||||
get_data: SensiboData,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
"""Tests for the Sonarr sensor platform."""
|
||||
from datetime import timedelta
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from aiopyarr import ArrException
|
||||
import pytest
|
||||
|
@ -25,7 +25,7 @@ async def test_sensors(
|
|||
hass: HomeAssistant,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_sonarr: MagicMock,
|
||||
entity_registry_enabled_by_default: AsyncMock,
|
||||
entity_registry_enabled_by_default: None,
|
||||
) -> None:
|
||||
"""Test the creation and values of the sensors."""
|
||||
registry = er.async_get(hass)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
"""Test the switchbot sensors."""
|
||||
|
||||
from homeassistant.components.sensor import ATTR_STATE_CLASS
|
||||
from homeassistant.components.switchbot.const import DOMAIN
|
||||
from homeassistant.const import (
|
||||
|
@ -18,7 +19,9 @@ from tests.common import MockConfigEntry
|
|||
from tests.components.bluetooth import inject_bluetooth_service_info
|
||||
|
||||
|
||||
async def test_sensors(hass: HomeAssistant, entity_registry_enabled_by_default) -> None:
|
||||
async def test_sensors(
|
||||
hass: HomeAssistant, entity_registry_enabled_by_default: None
|
||||
) -> None:
|
||||
"""Test setting up creates the sensors."""
|
||||
await async_setup_component(hass, DOMAIN, {})
|
||||
inject_bluetooth_service_info(hass, WOHAND_SERVICE_INFO)
|
||||
|
|
|
@ -210,7 +210,7 @@ async def test_uptime_sensors(
|
|||
hass: HomeAssistant,
|
||||
aioclient_mock: AiohttpClientMocker,
|
||||
mock_unifi_websocket,
|
||||
entity_registry_enabled_by_default,
|
||||
entity_registry_enabled_by_default: None,
|
||||
initial_uptime,
|
||||
event_uptime,
|
||||
new_uptime,
|
||||
|
@ -296,7 +296,7 @@ async def test_remove_sensors(
|
|||
hass: HomeAssistant,
|
||||
aioclient_mock: AiohttpClientMocker,
|
||||
mock_unifi_websocket,
|
||||
entity_registry_enabled_by_default,
|
||||
entity_registry_enabled_by_default: None,
|
||||
) -> None:
|
||||
"""Verify removing of clients work as expected."""
|
||||
wired_client = {
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
"""Test the UniFi Protect sensor platform."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
from unittest.mock import AsyncMock, Mock
|
||||
from unittest.mock import Mock
|
||||
|
||||
from pyunifiprotect.data import (
|
||||
NVR,
|
||||
|
@ -398,7 +397,7 @@ async def test_sensor_setup_camera(
|
|||
|
||||
async def test_sensor_setup_camera_with_last_trip_time(
|
||||
hass: HomeAssistant,
|
||||
entity_registry_enabled_by_default: AsyncMock,
|
||||
entity_registry_enabled_by_default: None,
|
||||
ufp: MockUFPFixture,
|
||||
doorbell: Camera,
|
||||
fixed_now: datetime,
|
||||
|
@ -474,7 +473,7 @@ async def test_sensor_update_alarm(
|
|||
|
||||
async def test_sensor_update_alarm_with_last_trip_time(
|
||||
hass: HomeAssistant,
|
||||
entity_registry_enabled_by_default: AsyncMock,
|
||||
entity_registry_enabled_by_default: None,
|
||||
ufp: MockUFPFixture,
|
||||
sensor_all: Sensor,
|
||||
fixed_now: datetime,
|
||||
|
|
Loading…
Add table
Reference in a new issue