Fix import-outside-toplevel pylint warnings in tests (#119389)

This commit is contained in:
epenet 2024-06-11 14:57:50 +02:00 committed by GitHub
parent 43db0e457c
commit 2c7022950c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 52 additions and 142 deletions

View file

@ -6,6 +6,12 @@ from unittest.mock import ANY, PropertyMock, patch
from arcam.fmj import ConnectionFailed, DecodeMode2CH, DecodeModeMCH, SourceCodes from arcam.fmj import ConnectionFailed, DecodeMode2CH, DecodeModeMCH, SourceCodes
import pytest import pytest
from homeassistant.components.arcam_fmj.const import (
SIGNAL_CLIENT_DATA,
SIGNAL_CLIENT_STARTED,
SIGNAL_CLIENT_STOPPED,
)
from homeassistant.components.arcam_fmj.media_player import ArcamFmj
from homeassistant.components.homeassistant import ( from homeassistant.components.homeassistant import (
DOMAIN as HA_DOMAIN, DOMAIN as HA_DOMAIN,
SERVICE_UPDATE_ENTITY, SERVICE_UPDATE_ENTITY,
@ -338,7 +344,6 @@ async def test_media_artist(player, state, source, dls, artist) -> None:
) )
async def test_media_title(player, state, source, channel, title) -> None: async def test_media_title(player, state, source, channel, title) -> None:
"""Test media title.""" """Test media title."""
from homeassistant.components.arcam_fmj.media_player import ArcamFmj
state.get_source.return_value = source state.get_source.return_value = source
with patch.object( with patch.object(
@ -354,11 +359,6 @@ async def test_media_title(player, state, source, channel, title) -> None:
async def test_added_to_hass(player, state) -> None: async def test_added_to_hass(player, state) -> None:
"""Test addition to hass.""" """Test addition to hass."""
from homeassistant.components.arcam_fmj.const import (
SIGNAL_CLIENT_DATA,
SIGNAL_CLIENT_STARTED,
SIGNAL_CLIENT_STOPPED,
)
with patch( with patch(
"homeassistant.components.arcam_fmj.media_player.async_dispatcher_connect" "homeassistant.components.arcam_fmj.media_player.async_dispatcher_connect"

View file

@ -3,6 +3,13 @@
import datetime import datetime
from decimal import Decimal from decimal import Decimal
from dsmr_parser.obis_references import (
BELGIUM_MBUS1_DEVICE_TYPE,
BELGIUM_MBUS1_EQUIPMENT_IDENTIFIER,
BELGIUM_MBUS1_METER_READING2,
)
from dsmr_parser.objects import CosemObject, MBusObject
from homeassistant.components.dsmr.const import DOMAIN from homeassistant.components.dsmr.const import DOMAIN
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -20,13 +27,6 @@ async def test_migrate_gas_to_mbus(
"""Test migration of unique_id.""" """Test migration of unique_id."""
(connection_factory, transport, protocol) = dsmr_connection_fixture (connection_factory, transport, protocol) = dsmr_connection_fixture
from dsmr_parser.obis_references import (
BELGIUM_MBUS1_DEVICE_TYPE,
BELGIUM_MBUS1_EQUIPMENT_IDENTIFIER,
BELGIUM_MBUS1_METER_READING2,
)
from dsmr_parser.objects import CosemObject, MBusObject
mock_entry = MockConfigEntry( mock_entry = MockConfigEntry(
domain=DOMAIN, domain=DOMAIN,
unique_id="/dev/ttyUSB0", unique_id="/dev/ttyUSB0",
@ -118,13 +118,6 @@ async def test_migrate_gas_to_mbus_exists(
"""Test migration of unique_id.""" """Test migration of unique_id."""
(connection_factory, transport, protocol) = dsmr_connection_fixture (connection_factory, transport, protocol) = dsmr_connection_fixture
from dsmr_parser.obis_references import (
BELGIUM_MBUS1_DEVICE_TYPE,
BELGIUM_MBUS1_EQUIPMENT_IDENTIFIER,
BELGIUM_MBUS1_METER_READING2,
)
from dsmr_parser.objects import CosemObject, MBusObject
mock_entry = MockConfigEntry( mock_entry = MockConfigEntry(
domain=DOMAIN, domain=DOMAIN,
unique_id="/dev/ttyUSB0", unique_id="/dev/ttyUSB0",

View file

@ -11,6 +11,33 @@ from decimal import Decimal
from itertools import chain, repeat from itertools import chain, repeat
from unittest.mock import DEFAULT, MagicMock from unittest.mock import DEFAULT, MagicMock
from dsmr_parser.obis_references import (
BELGIUM_CURRENT_AVERAGE_DEMAND,
BELGIUM_MAXIMUM_DEMAND_MONTH,
BELGIUM_MBUS1_DEVICE_TYPE,
BELGIUM_MBUS1_EQUIPMENT_IDENTIFIER,
BELGIUM_MBUS1_METER_READING1,
BELGIUM_MBUS1_METER_READING2,
BELGIUM_MBUS2_DEVICE_TYPE,
BELGIUM_MBUS2_EQUIPMENT_IDENTIFIER,
BELGIUM_MBUS2_METER_READING1,
BELGIUM_MBUS2_METER_READING2,
BELGIUM_MBUS3_DEVICE_TYPE,
BELGIUM_MBUS3_EQUIPMENT_IDENTIFIER,
BELGIUM_MBUS3_METER_READING1,
BELGIUM_MBUS3_METER_READING2,
BELGIUM_MBUS4_DEVICE_TYPE,
BELGIUM_MBUS4_EQUIPMENT_IDENTIFIER,
BELGIUM_MBUS4_METER_READING1,
BELGIUM_MBUS4_METER_READING2,
CURRENT_ELECTRICITY_USAGE,
ELECTRICITY_ACTIVE_TARIFF,
ELECTRICITY_EXPORTED_TOTAL,
ELECTRICITY_IMPORTED_TOTAL,
GAS_METER_READING,
HOURLY_GAS_METER_READING,
)
from dsmr_parser.objects import CosemObject, MBusObject
import pytest import pytest
from homeassistant.components.sensor import ( from homeassistant.components.sensor import (
@ -41,13 +68,6 @@ async def test_default_setup(
"""Test the default setup.""" """Test the default setup."""
(connection_factory, transport, protocol) = dsmr_connection_fixture (connection_factory, transport, protocol) = dsmr_connection_fixture
from dsmr_parser.obis_references import (
CURRENT_ELECTRICITY_USAGE,
ELECTRICITY_ACTIVE_TARIFF,
GAS_METER_READING,
)
from dsmr_parser.objects import CosemObject, MBusObject
entry_data = { entry_data = {
"port": "/dev/ttyUSB0", "port": "/dev/ttyUSB0",
"dsmr_version": "2.2", "dsmr_version": "2.2",
@ -176,12 +196,6 @@ async def test_setup_only_energy(
"""Test the default setup.""" """Test the default setup."""
(connection_factory, transport, protocol) = dsmr_connection_fixture (connection_factory, transport, protocol) = dsmr_connection_fixture
from dsmr_parser.obis_references import (
CURRENT_ELECTRICITY_USAGE,
ELECTRICITY_ACTIVE_TARIFF,
)
from dsmr_parser.objects import CosemObject
entry_data = { entry_data = {
"port": "/dev/ttyUSB0", "port": "/dev/ttyUSB0",
"dsmr_version": "2.2", "dsmr_version": "2.2",
@ -230,12 +244,6 @@ async def test_v4_meter(hass: HomeAssistant, dsmr_connection_fixture) -> None:
"""Test if v4 meter is correctly parsed.""" """Test if v4 meter is correctly parsed."""
(connection_factory, transport, protocol) = dsmr_connection_fixture (connection_factory, transport, protocol) = dsmr_connection_fixture
from dsmr_parser.obis_references import (
ELECTRICITY_ACTIVE_TARIFF,
HOURLY_GAS_METER_READING,
)
from dsmr_parser.objects import CosemObject, MBusObject
entry_data = { entry_data = {
"port": "/dev/ttyUSB0", "port": "/dev/ttyUSB0",
"dsmr_version": "4", "dsmr_version": "4",
@ -316,12 +324,6 @@ async def test_v5_meter(
"""Test if v5 meter is correctly parsed.""" """Test if v5 meter is correctly parsed."""
(connection_factory, transport, protocol) = dsmr_connection_fixture (connection_factory, transport, protocol) = dsmr_connection_fixture
from dsmr_parser.obis_references import (
ELECTRICITY_ACTIVE_TARIFF,
HOURLY_GAS_METER_READING,
)
from dsmr_parser.objects import CosemObject, MBusObject
entry_data = { entry_data = {
"port": "/dev/ttyUSB0", "port": "/dev/ttyUSB0",
"dsmr_version": "5", "dsmr_version": "5",
@ -388,13 +390,6 @@ async def test_luxembourg_meter(hass: HomeAssistant, dsmr_connection_fixture) ->
"""Test if v5 meter is correctly parsed.""" """Test if v5 meter is correctly parsed."""
(connection_factory, transport, protocol) = dsmr_connection_fixture (connection_factory, transport, protocol) = dsmr_connection_fixture
from dsmr_parser.obis_references import (
ELECTRICITY_EXPORTED_TOTAL,
ELECTRICITY_IMPORTED_TOTAL,
HOURLY_GAS_METER_READING,
)
from dsmr_parser.objects import CosemObject, MBusObject
entry_data = { entry_data = {
"port": "/dev/ttyUSB0", "port": "/dev/ttyUSB0",
"dsmr_version": "5L", "dsmr_version": "5L",
@ -477,25 +472,6 @@ async def test_belgian_meter(hass: HomeAssistant, dsmr_connection_fixture) -> No
"""Test if Belgian meter is correctly parsed.""" """Test if Belgian meter is correctly parsed."""
(connection_factory, transport, protocol) = dsmr_connection_fixture (connection_factory, transport, protocol) = dsmr_connection_fixture
from dsmr_parser.obis_references import (
BELGIUM_CURRENT_AVERAGE_DEMAND,
BELGIUM_MAXIMUM_DEMAND_MONTH,
BELGIUM_MBUS1_DEVICE_TYPE,
BELGIUM_MBUS1_EQUIPMENT_IDENTIFIER,
BELGIUM_MBUS1_METER_READING2,
BELGIUM_MBUS2_DEVICE_TYPE,
BELGIUM_MBUS2_EQUIPMENT_IDENTIFIER,
BELGIUM_MBUS2_METER_READING1,
BELGIUM_MBUS3_DEVICE_TYPE,
BELGIUM_MBUS3_EQUIPMENT_IDENTIFIER,
BELGIUM_MBUS3_METER_READING2,
BELGIUM_MBUS4_DEVICE_TYPE,
BELGIUM_MBUS4_EQUIPMENT_IDENTIFIER,
BELGIUM_MBUS4_METER_READING1,
ELECTRICITY_ACTIVE_TARIFF,
)
from dsmr_parser.objects import CosemObject, MBusObject
entry_data = { entry_data = {
"port": "/dev/ttyUSB0", "port": "/dev/ttyUSB0",
"dsmr_version": "5B", "dsmr_version": "5B",
@ -679,22 +655,6 @@ async def test_belgian_meter_alt(hass: HomeAssistant, dsmr_connection_fixture) -
"""Test if Belgian meter is correctly parsed.""" """Test if Belgian meter is correctly parsed."""
(connection_factory, transport, protocol) = dsmr_connection_fixture (connection_factory, transport, protocol) = dsmr_connection_fixture
from dsmr_parser.obis_references import (
BELGIUM_MBUS1_DEVICE_TYPE,
BELGIUM_MBUS1_EQUIPMENT_IDENTIFIER,
BELGIUM_MBUS1_METER_READING1,
BELGIUM_MBUS2_DEVICE_TYPE,
BELGIUM_MBUS2_EQUIPMENT_IDENTIFIER,
BELGIUM_MBUS2_METER_READING2,
BELGIUM_MBUS3_DEVICE_TYPE,
BELGIUM_MBUS3_EQUIPMENT_IDENTIFIER,
BELGIUM_MBUS3_METER_READING1,
BELGIUM_MBUS4_DEVICE_TYPE,
BELGIUM_MBUS4_EQUIPMENT_IDENTIFIER,
BELGIUM_MBUS4_METER_READING2,
)
from dsmr_parser.objects import CosemObject, MBusObject
entry_data = { entry_data = {
"port": "/dev/ttyUSB0", "port": "/dev/ttyUSB0",
"dsmr_version": "5B", "dsmr_version": "5B",
@ -842,20 +802,6 @@ async def test_belgian_meter_mbus(hass: HomeAssistant, dsmr_connection_fixture)
"""Test if Belgian meter is correctly parsed.""" """Test if Belgian meter is correctly parsed."""
(connection_factory, transport, protocol) = dsmr_connection_fixture (connection_factory, transport, protocol) = dsmr_connection_fixture
from dsmr_parser.obis_references import (
BELGIUM_MBUS1_DEVICE_TYPE,
BELGIUM_MBUS1_EQUIPMENT_IDENTIFIER,
BELGIUM_MBUS2_DEVICE_TYPE,
BELGIUM_MBUS2_EQUIPMENT_IDENTIFIER,
BELGIUM_MBUS3_DEVICE_TYPE,
BELGIUM_MBUS3_EQUIPMENT_IDENTIFIER,
BELGIUM_MBUS3_METER_READING2,
BELGIUM_MBUS4_DEVICE_TYPE,
BELGIUM_MBUS4_METER_READING1,
ELECTRICITY_ACTIVE_TARIFF,
)
from dsmr_parser.objects import CosemObject, MBusObject
entry_data = { entry_data = {
"port": "/dev/ttyUSB0", "port": "/dev/ttyUSB0",
"dsmr_version": "5B", "dsmr_version": "5B",
@ -963,9 +909,6 @@ async def test_belgian_meter_low(hass: HomeAssistant, dsmr_connection_fixture) -
"""Test if Belgian meter is correctly parsed.""" """Test if Belgian meter is correctly parsed."""
(connection_factory, transport, protocol) = dsmr_connection_fixture (connection_factory, transport, protocol) = dsmr_connection_fixture
from dsmr_parser.obis_references import ELECTRICITY_ACTIVE_TARIFF
from dsmr_parser.objects import CosemObject
entry_data = { entry_data = {
"port": "/dev/ttyUSB0", "port": "/dev/ttyUSB0",
"dsmr_version": "5B", "dsmr_version": "5B",
@ -1012,12 +955,6 @@ async def test_swedish_meter(hass: HomeAssistant, dsmr_connection_fixture) -> No
"""Test if v5 meter is correctly parsed.""" """Test if v5 meter is correctly parsed."""
(connection_factory, transport, protocol) = dsmr_connection_fixture (connection_factory, transport, protocol) = dsmr_connection_fixture
from dsmr_parser.obis_references import (
ELECTRICITY_EXPORTED_TOTAL,
ELECTRICITY_IMPORTED_TOTAL,
)
from dsmr_parser.objects import CosemObject
entry_data = { entry_data = {
"port": "/dev/ttyUSB0", "port": "/dev/ttyUSB0",
"dsmr_version": "5S", "dsmr_version": "5S",
@ -1084,12 +1021,6 @@ async def test_easymeter(hass: HomeAssistant, dsmr_connection_fixture) -> None:
"""Test if Q3D meter is correctly parsed.""" """Test if Q3D meter is correctly parsed."""
(connection_factory, transport, protocol) = dsmr_connection_fixture (connection_factory, transport, protocol) = dsmr_connection_fixture
from dsmr_parser.obis_references import (
ELECTRICITY_EXPORTED_TOTAL,
ELECTRICITY_IMPORTED_TOTAL,
)
from dsmr_parser.objects import CosemObject
entry_data = { entry_data = {
"port": "/dev/ttyUSB0", "port": "/dev/ttyUSB0",
"dsmr_version": "Q3D", "dsmr_version": "Q3D",
@ -1248,11 +1179,6 @@ async def test_connection_errors_retry(
@patch("homeassistant.components.dsmr.sensor.DEFAULT_RECONNECT_INTERVAL", 0) @patch("homeassistant.components.dsmr.sensor.DEFAULT_RECONNECT_INTERVAL", 0)
async def test_reconnect(hass: HomeAssistant, dsmr_connection_fixture) -> None: async def test_reconnect(hass: HomeAssistant, dsmr_connection_fixture) -> None:
"""If transport disconnects, the connection should be retried.""" """If transport disconnects, the connection should be retried."""
from dsmr_parser.obis_references import (
CURRENT_ELECTRICITY_USAGE,
ELECTRICITY_ACTIVE_TARIFF,
)
from dsmr_parser.objects import CosemObject
(connection_factory, transport, protocol) = dsmr_connection_fixture (connection_factory, transport, protocol) = dsmr_connection_fixture
@ -1334,9 +1260,6 @@ async def test_gas_meter_providing_energy_reading(
"""Test that gas providing energy readings use the correct device class.""" """Test that gas providing energy readings use the correct device class."""
(connection_factory, transport, protocol) = dsmr_connection_fixture (connection_factory, transport, protocol) = dsmr_connection_fixture
from dsmr_parser.obis_references import GAS_METER_READING
from dsmr_parser.objects import MBusObject
entry_data = { entry_data = {
"port": "/dev/ttyUSB0", "port": "/dev/ttyUSB0",
"dsmr_version": "2.2", "dsmr_version": "2.2",

View file

@ -8,6 +8,7 @@ from homeassistant import config_entries
from homeassistant.components.izone.const import DISPATCH_CONTROLLER_DISCOVERED, IZONE from homeassistant.components.izone.const import DISPATCH_CONTROLLER_DISCOVERED, IZONE
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType from homeassistant.data_entry_flow import FlowResultType
from homeassistant.helpers.dispatcher import async_dispatcher_send
@pytest.fixture @pytest.fixture
@ -20,8 +21,6 @@ def mock_disco():
def _mock_start_discovery(hass, mock_disco): def _mock_start_discovery(hass, mock_disco):
from homeassistant.helpers.dispatcher import async_dispatcher_send
def do_disovered(*args): def do_disovered(*args):
async_dispatcher_send(hass, DISPATCH_CONTROLLER_DISCOVERED, True) async_dispatcher_send(hass, DISPATCH_CONTROLLER_DISCOVERED, True)
return mock_disco return mock_disco

View file

@ -4,6 +4,7 @@ from unittest.mock import MagicMock
import pytest import pytest
from homeassistant.components.litterrobot.sensor import icon_for_gauge_level
from homeassistant.components.sensor import DOMAIN as PLATFORM_DOMAIN, SensorDeviceClass from homeassistant.components.sensor import DOMAIN as PLATFORM_DOMAIN, SensorDeviceClass
from homeassistant.const import PERCENTAGE, STATE_UNKNOWN, UnitOfMass from homeassistant.const import PERCENTAGE, STATE_UNKNOWN, UnitOfMass
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -47,7 +48,6 @@ async def test_sleep_time_sensor_with_sleep_disabled(
async def test_gauge_icon() -> None: async def test_gauge_icon() -> None:
"""Test icon generator for gauge sensor.""" """Test icon generator for gauge sensor."""
from homeassistant.components.litterrobot.sensor import icon_for_gauge_level
GAUGE_EMPTY = "mdi:gauge-empty" GAUGE_EMPTY = "mdi:gauge-empty"
GAUGE_LOW = "mdi:gauge-low" GAUGE_LOW = "mdi:gauge-low"

View file

@ -12,6 +12,7 @@ import time
from typing import Any, TypedDict from typing import Any, TypedDict
from unittest.mock import ANY, MagicMock, Mock, call, mock_open, patch from unittest.mock import ANY, MagicMock, Mock, call, mock_open, patch
import certifi
from freezegun.api import FrozenDateTimeFactory from freezegun.api import FrozenDateTimeFactory
import paho.mqtt.client as paho_mqtt import paho.mqtt.client as paho_mqtt
import pytest import pytest
@ -2479,8 +2480,6 @@ async def test_setup_uses_certificate_on_certificate_set_to_auto_and_insecure(
assert calls assert calls
import certifi
expected_certificate = certifi.where() expected_certificate = certifi.where()
assert calls[0][0] == expected_certificate assert calls[0][0] == expected_certificate

View file

@ -19,6 +19,7 @@ from sqlalchemy import (
distinct, distinct,
) )
from sqlalchemy.orm import declarative_base from sqlalchemy.orm import declarative_base
from sqlalchemy.orm.session import Session
from homeassistant.core import Event, EventOrigin, State, split_entity_id from homeassistant.core import Event, EventOrigin, State, split_entity_id
from homeassistant.helpers.json import JSONEncoder from homeassistant.helpers.json import JSONEncoder
@ -141,8 +142,6 @@ class RecorderRuns(Base): # type: ignore[valid-type,misc]
Specify point_in_time if you want to know which existed at that point Specify point_in_time if you want to know which existed at that point
in time inside the run. in time inside the run.
""" """
from sqlalchemy.orm.session import Session
session = Session.object_session(self) session = Session.object_session(self)
assert session is not None, "RecorderRuns need to be persisted" assert session is not None, "RecorderRuns need to be persisted"

View file

@ -10,7 +10,7 @@ from unittest.mock import MagicMock, Mock, patch
import pytest import pytest
from sqlalchemy import lambda_stmt, text from sqlalchemy import lambda_stmt, text
from sqlalchemy.engine.result import ChunkedIteratorResult from sqlalchemy.engine.result import ChunkedIteratorResult
from sqlalchemy.exc import SQLAlchemyError from sqlalchemy.exc import OperationalError, SQLAlchemyError
from sqlalchemy.sql.elements import TextClause from sqlalchemy.sql.elements import TextClause
from sqlalchemy.sql.lambdas import StatementLambdaElement from sqlalchemy.sql.lambdas import StatementLambdaElement
@ -73,7 +73,6 @@ async def test_session_scope_not_setup(
async def test_recorder_bad_execute(hass: HomeAssistant, setup_recorder: None) -> None: async def test_recorder_bad_execute(hass: HomeAssistant, setup_recorder: None) -> None:
"""Bad execute, retry 3 times.""" """Bad execute, retry 3 times."""
from sqlalchemy.exc import SQLAlchemyError
def to_native(validate_entity_id=True): def to_native(validate_entity_id=True):
"""Raise exception.""" """Raise exception."""
@ -854,7 +853,6 @@ async def test_write_lock_db(
tmp_path: Path, tmp_path: Path,
) -> None: ) -> None:
"""Test database write lock.""" """Test database write lock."""
from sqlalchemy.exc import OperationalError
# Use file DB, in memory DB cannot do write locks. # Use file DB, in memory DB cannot do write locks.
config = { config = {

View file

@ -2,6 +2,9 @@
from unittest.mock import Mock, PropertyMock, patch from unittest.mock import Mock, PropertyMock, patch
import pyspcwebgw
from pyspcwebgw.const import AreaMode
from homeassistant.bootstrap import async_setup_component from homeassistant.bootstrap import async_setup_component
from homeassistant.components.spc import DATA_API from homeassistant.components.spc import DATA_API
from homeassistant.const import STATE_ALARM_ARMED_AWAY, STATE_ALARM_DISARMED from homeassistant.const import STATE_ALARM_ARMED_AWAY, STATE_ALARM_DISARMED
@ -32,8 +35,6 @@ async def test_invalid_device_config(hass: HomeAssistant, monkeypatch) -> None:
async def test_update_alarm_device(hass: HomeAssistant) -> None: async def test_update_alarm_device(hass: HomeAssistant) -> None:
"""Test that alarm panel state changes on incoming websocket data.""" """Test that alarm panel state changes on incoming websocket data."""
import pyspcwebgw
from pyspcwebgw.const import AreaMode
config = {"spc": {"api_url": "http://localhost/", "ws_url": "ws://localhost/"}} config = {"spc": {"api_url": "http://localhost/", "ws_url": "ws://localhost/"}}

View file

@ -3,6 +3,8 @@
from datetime import datetime, timedelta from datetime import datetime, timedelta
from unittest.mock import patch from unittest.mock import patch
from astral import LocationInfo
import astral.sun
from freezegun import freeze_time from freezegun import freeze_time
import pytest import pytest
@ -25,9 +27,6 @@ async def test_setting_rising(hass: HomeAssistant) -> None:
await hass.async_block_till_done() await hass.async_block_till_done()
state = hass.states.get(entity.ENTITY_ID) state = hass.states.get(entity.ENTITY_ID)
from astral import LocationInfo
import astral.sun
utc_today = utc_now.date() utc_today = utc_now.date()
location = LocationInfo( location = LocationInfo(

View file

@ -1,5 +1,6 @@
"""Test the UPB Control config flow.""" """Test the UPB Control config flow."""
from asyncio import TimeoutError
from unittest.mock import MagicMock, PropertyMock, patch from unittest.mock import MagicMock, PropertyMock, patch
from homeassistant import config_entries from homeassistant import config_entries
@ -84,7 +85,6 @@ async def test_form_user_with_tcp_upb(hass: HomeAssistant) -> None:
async def test_form_cannot_connect(hass: HomeAssistant) -> None: async def test_form_cannot_connect(hass: HomeAssistant) -> None:
"""Test we handle cannot connect error.""" """Test we handle cannot connect error."""
from asyncio import TimeoutError
with patch( with patch(
"homeassistant.components.upb.config_flow.asyncio.timeout", "homeassistant.components.upb.config_flow.asyncio.timeout",

View file

@ -5,6 +5,7 @@ from unittest.mock import AsyncMock, patch
import pytest import pytest
from syrupy import SnapshotAssertion from syrupy import SnapshotAssertion
from homeassistant.components.v2c.sensor import _METER_ERROR_OPTIONS
from homeassistant.const import Platform from homeassistant.const import Platform
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er from homeassistant.helpers import entity_registry as er
@ -27,8 +28,6 @@ async def test_sensor(
await init_integration(hass, mock_config_entry) await init_integration(hass, mock_config_entry)
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id) await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
from homeassistant.components.v2c.sensor import _METER_ERROR_OPTIONS
assert [ assert [
"no_error", "no_error",
"communication", "communication",