mirror of
https://github.com/home-assistant/core.git
synced 2026-09-25 17:04:04 -04:00
Fix
This commit is contained in:
@@ -16,7 +16,7 @@ async def async_setup_entry(
|
||||
hass: HomeAssistant,
|
||||
entry: FlussConfigEntry,
|
||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||
) -> bool:
|
||||
) -> None:
|
||||
"""Set up the Fluss Devices, filtering out any invalid payloads."""
|
||||
coordinator = entry.runtime_data
|
||||
devices = coordinator.data
|
||||
@@ -25,7 +25,6 @@ async def async_setup_entry(
|
||||
FlussButton(coordinator, device_id, device)
|
||||
for device_id, device in devices.items()
|
||||
)
|
||||
return True
|
||||
|
||||
|
||||
class FlussButton(FlussEntity, ButtonEntity):
|
||||
|
||||
@@ -41,7 +41,7 @@ class FlussConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
errors["base"] = "cannot_connect"
|
||||
except FlussApiClientAuthenticationError:
|
||||
errors["base"] = "invalid_auth"
|
||||
except Exception:
|
||||
except Exception: # noqa: BLE001
|
||||
LOGGER.exception("Unexpected exception occurred")
|
||||
errors["base"] = "unknown"
|
||||
if not errors:
|
||||
|
||||
@@ -7,16 +7,15 @@ from typing import Any
|
||||
from fluss_api import (
|
||||
FlussApiClient,
|
||||
FlussApiClientAuthenticationError,
|
||||
FlussApiClientCommunicationError,
|
||||
FlussApiClientError,
|
||||
)
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryAuthFailed
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||
from homeassistant.util import slugify
|
||||
from homeassistant.exceptions import ConfigEntryAuthFailed
|
||||
|
||||
from .const import LOGGER, UPDATE_INTERVAL_TIMEDELTA
|
||||
|
||||
|
||||
@@ -6,5 +6,6 @@
|
||||
"documentation": "https://www.home-assistant.io/integrations/fluss",
|
||||
"iot_class": "cloud_polling",
|
||||
"loggers": ["fluss-api"],
|
||||
"quality_scale": "bronze",
|
||||
"requirements": ["fluss-api==0.1.9.17"]
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
rules:
|
||||
# Bronze
|
||||
action-setup: exempt
|
||||
action-setup:
|
||||
status: exempt
|
||||
comment: |
|
||||
No actions present
|
||||
appropriate-polling: done
|
||||
brands: done
|
||||
common-modules: done
|
||||
@@ -37,20 +40,23 @@ rules:
|
||||
status: exempt
|
||||
comment: |
|
||||
Not needed
|
||||
discovery: done
|
||||
discovery: todo
|
||||
stale-devices: todo
|
||||
diagnostics: todo
|
||||
exception-translations: todo
|
||||
icon-translations: exempt
|
||||
icon-translations:
|
||||
status: exempt
|
||||
comment: |
|
||||
No icons used
|
||||
reconfiguration-flow: todo
|
||||
dynamic-devices: todo
|
||||
discovery-update-info: exempt
|
||||
repair-issues: exempt
|
||||
discovery-update-info: todo
|
||||
repair-issues:
|
||||
status: exempt
|
||||
comment: |
|
||||
No issues to repair
|
||||
docs-use-cases: done
|
||||
docs-supported-devices:
|
||||
status: exempt
|
||||
comment: |
|
||||
There is only one device
|
||||
docs-supported-devices: todo
|
||||
docs-supported-functions: done
|
||||
docs-data-update: todo
|
||||
docs-known-limitations: done
|
||||
@@ -60,4 +66,4 @@ rules:
|
||||
# Platinum
|
||||
async-dependency: done
|
||||
inject-websession: done
|
||||
strict-typing: todo
|
||||
strict-typing: todo
|
||||
|
||||
@@ -2063,7 +2063,7 @@
|
||||
"iot_class": "cloud_polling"
|
||||
},
|
||||
"fluss": {
|
||||
"name": "Fluss +",
|
||||
"name": "Fluss+",
|
||||
"integration_type": "hub",
|
||||
"config_flow": true,
|
||||
"iot_class": "cloud_polling"
|
||||
|
||||
@@ -20,7 +20,7 @@ from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"side_effect, expected_exception",
|
||||
("side_effect", "expected_exception"),
|
||||
[
|
||||
(FlussApiClientAuthenticationError, ConfigEntryAuthFailed),
|
||||
(FlussApiClientCommunicationError, ConfigEntryNotReady),
|
||||
@@ -70,7 +70,9 @@ async def test_async_unload_entry(
|
||||
assert mock_config_entry.state is ConfigEntryState.LOADED
|
||||
|
||||
# Test unloading
|
||||
with patch("homeassistant.components.fluss.async_unload_platforms", return_value=True):
|
||||
with patch(
|
||||
"homeassistant.components.fluss.async_unload_platforms", return_value=True
|
||||
):
|
||||
assert await hass.config_entries.async_unload(mock_config_entry.entry_id)
|
||||
assert mock_config_entry.state is ConfigEntryState.NOT_LOADED
|
||||
|
||||
@@ -87,4 +89,4 @@ async def test_platforms_forwarded(
|
||||
assert mock_config_entry.state is ConfigEntryState.LOADED
|
||||
hass.config_entries.async_forward_entry_setups.assert_called_with(
|
||||
mock_config_entry, [Platform.BUTTON]
|
||||
)
|
||||
)
|
||||
|
||||
@@ -4,7 +4,6 @@ from __future__ import annotations
|
||||
|
||||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
from fluss_api import FlussApiClient
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.fluss.const import DOMAIN
|
||||
|
||||
@@ -18,7 +18,6 @@ from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
from tests.common import MockConfigEntry, snapshot_platform
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_async_setup_entry_multiple_devices(
|
||||
hass: HomeAssistant,
|
||||
mock_api_client_multiple_devices: AsyncMock,
|
||||
@@ -36,7 +35,6 @@ async def test_async_setup_entry_multiple_devices(
|
||||
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_button_press_success(
|
||||
hass: HomeAssistant,
|
||||
mock_api_client: FlussApiClient,
|
||||
@@ -66,7 +64,6 @@ async def test_button_press_success(
|
||||
mock_api_client.async_trigger_device.assert_called_once_with("1")
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_button_press_error(
|
||||
hass: HomeAssistant,
|
||||
mock_api_client: FlussApiClient,
|
||||
@@ -87,7 +84,6 @@ async def test_button_press_error(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_no_devices_setup(
|
||||
hass: HomeAssistant,
|
||||
mock_api_client: FlussApiClient,
|
||||
@@ -104,7 +100,6 @@ async def test_no_devices_setup(
|
||||
assert hass.states.get("button.test_device") is None
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_unload_entry(
|
||||
hass: HomeAssistant,
|
||||
init_integration: MockConfigEntry,
|
||||
|
||||
@@ -14,8 +14,6 @@ from homeassistant.const import CONF_API_KEY
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_show_form(hass: HomeAssistant) -> None:
|
||||
"""Test that the form is shown."""
|
||||
|
||||
@@ -9,10 +9,8 @@ from fluss_api import (
|
||||
)
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.fluss import async_setup_entry
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
Reference in New Issue
Block a user