diff --git a/.github/workflows/constraints.txt b/.github/workflows/constraints.txt index 01312b7..8c921ed 100644 --- a/.github/workflows/constraints.txt +++ b/.github/workflows/constraints.txt @@ -2,4 +2,4 @@ pip==24.0 pre-commit==3.6.2 black==23.11.0 flake8==7.0.0 -reorder-python-imports==3.12.0 \ No newline at end of file +reorder-python-imports==3.12.0 diff --git a/custom_components/sunspec/config_flow.py b/custom_components/sunspec/config_flow.py index 0eda55e..e94f42a 100644 --- a/custom_components/sunspec/config_flow.py +++ b/custom_components/sunspec/config_flow.py @@ -1,10 +1,11 @@ """Adds config flow for SunSpec.""" + import logging -import homeassistant.helpers.config_validation as cv -import voluptuous as vol from homeassistant import config_entries from homeassistant.core import callback +import homeassistant.helpers.config_validation as cv +import voluptuous as vol from . import SCAN_INTERVAL from .api import SunSpecApiClient diff --git a/custom_components/sunspec/entity.py b/custom_components/sunspec/entity.py index 756b277..0ace0c7 100644 --- a/custom_components/sunspec/entity.py +++ b/custom_components/sunspec/entity.py @@ -1,4 +1,5 @@ """SunSpecEntity class""" + from homeassistant.helpers.update_coordinator import CoordinatorEntity from .const import DOMAIN diff --git a/tests/__init__.py b/tests/__init__.py index 8f6c7ec..a6a9d85 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,21 +1,21 @@ """Tests for SunSpec integration.""" + from __future__ import annotations from typing import Any from unittest.mock import Mock from unittest.mock import patch -from custom_components.sunspec import DOMAIN -from custom_components.sunspec import get_sunspec_unique_id -from custom_components.sunspec.api import ( - SunSpecApiClient, -) from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant from homeassistant.helpers import entity_registry as er from homeassistant.helpers.update_coordinator import DataUpdateCoordinator from pytest_homeassistant_custom_component.common import MockConfigEntry +from custom_components.sunspec import DOMAIN +from custom_components.sunspec import get_sunspec_unique_id +from custom_components.sunspec.api import SunSpecApiClient + from .const import MOCK_CONFIG TEST_CONFIG_ENTRY_ID = "77889900aa" diff --git a/tests/const.py b/tests/const.py index db73d52..a2edf34 100644 --- a/tests/const.py +++ b/tests/const.py @@ -1,4 +1,5 @@ """Constants for SunSpec tests.""" + from custom_components.sunspec.const import CONF_ENABLED_MODELS from custom_components.sunspec.const import CONF_HOST from custom_components.sunspec.const import CONF_PORT diff --git a/tests/test_config_flow.py b/tests/test_config_flow.py index 213f0ce..685dc7e 100644 --- a/tests/test_config_flow.py +++ b/tests/test_config_flow.py @@ -1,13 +1,15 @@ """Test SunSpec config flow.""" + from unittest.mock import patch +from homeassistant import config_entries +from homeassistant import data_entry_flow import pytest +from pytest_homeassistant_custom_component.common import MockConfigEntry + from custom_components.sunspec.const import CONF_ENABLED_MODELS from custom_components.sunspec.const import CONF_SCAN_INTERVAL from custom_components.sunspec.const import DOMAIN -from homeassistant import config_entries -from homeassistant import data_entry_flow -from pytest_homeassistant_custom_component.common import MockConfigEntry from . import MockSunSpecDataUpdateCoordinator from .const import MOCK_CONFIG diff --git a/tests/test_sensor.py b/tests/test_sensor.py index ab6072f..76ae28c 100644 --- a/tests/test_sensor.py +++ b/tests/test_sensor.py @@ -1,8 +1,9 @@ """Test SunSpec sensor.""" -from custom_components.sunspec.sensor import ICON_DC_AMPS + from homeassistant.core import HomeAssistant -from . import setup_mock_sunspec_config_entry +from custom_components.sunspec.sensor import ICON_DC_AMPS + from . import TEST_INVERTER_MM_SENSOR_POWER_ENTITY_ID from . import TEST_INVERTER_MM_SENSOR_STATE_ENTITY_ID from . import TEST_INVERTER_PREFIX_SENSOR_DC_ENTITY_ID @@ -11,6 +12,7 @@ from . import TEST_INVERTER_SENSOR_POWER_ENTITY_ID from . import TEST_INVERTER_SENSOR_STATE_ENTITY_ID from . import TEST_INVERTER_SENSOR_VAR_ID +from . import setup_mock_sunspec_config_entry from .const import MOCK_CONFIG_MM from .const import MOCK_CONFIG_PREFIX