fixing test errors
This commit is contained in:
@@ -2,17 +2,16 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from fluss_api import FlussApiClient
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.fluss.coordinator import FlussDataUpdateCoordinator
|
||||
from homeassistant.config_entries import ConfigEntry, MockConfigEntry
|
||||
from homeassistant.const import CONF_API_KEY
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_config_entry() -> MockConfigEntry:
|
||||
@@ -29,12 +28,13 @@ def mock_config_entry() -> MockConfigEntry:
|
||||
def mock_api_client() -> MagicMock:
|
||||
"""Mock Fluss API client."""
|
||||
client = MagicMock(spec=FlussApiClient)
|
||||
client.async_get_devices = MagicMock(return_value={"devices": [{"deviceId": "1", "deviceName": "Test Device"}]})
|
||||
client.async_get_devices = MagicMock(
|
||||
return_value={"devices": [{"deviceId": "1", "deviceName": "Test Device"}]}
|
||||
)
|
||||
client.async_trigger_device = MagicMock()
|
||||
return client
|
||||
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
async def init_integration(
|
||||
hass: HomeAssistant, mock_config_entry: MockConfigEntry, mock_api_client: MagicMock
|
||||
@@ -44,4 +44,4 @@ async def init_integration(
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
assert await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
return mock_config_entry
|
||||
return mock_config_entry
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from fluss_api import FlussApiClient
|
||||
@@ -125,4 +124,4 @@ async def test_unload_entry(
|
||||
assert await hass.config_entries.async_unload(init_integration.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
assert init_integration.state is ConfigEntryState.NOT_LOADED
|
||||
assert hass.states.get("button.test_device") is None
|
||||
assert hass.states.get("button.test_device") is None
|
||||
|
||||
@@ -10,7 +10,6 @@ from fluss_api import (
|
||||
FlussApiClientCommunicationError,
|
||||
)
|
||||
import pytest
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.fluss.config_flow import STEP_USER_DATA_SCHEMA
|
||||
from homeassistant.components.fluss.const import DOMAIN
|
||||
@@ -113,4 +112,4 @@ async def test_single_instance_allowed(hass: HomeAssistant) -> None:
|
||||
)
|
||||
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "single_instance_allowed"
|
||||
assert result["reason"] == "single_instance_allowed"
|
||||
|
||||
@@ -11,8 +11,9 @@ from fluss_api import (
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.fluss import PLATFORMS, async_setup_entry
|
||||
from homeassistant.config_entries import ConfigEntryState, MockConfigEntry
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -87,4 +88,4 @@ async def test_async_setup_entry_success(mock_hass, mock_entry) -> None:
|
||||
assert mock_entry.runtime_data == mock_api_client
|
||||
mock_hass.config_entries.async_forward_entry_setups.assert_called_once_with(
|
||||
mock_entry, PLATFORMS
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user