hass-core/tests/components/apsystems/conftest.py
Marlon 3604a34823
Post review comments on APsystems ()
* Cleanup for apsystems and fix for strings

* Migrate to typed ConfigEntry Data for apsystems

* Improve strings for apsystems

* Improve config flow tests for apsystems by cleaning up fixtures

* Do not use Dataclass for Config Entry Typing

* Improve translations for apsystems by using sentence case and removing an apostrophe

* Rename test fixture and remove unnecessary comment in tests from apsystems

* Remove default override with default in coordinator from apsystems
2024-05-15 19:56:12 +02:00

29 lines
890 B
Python

"""Common fixtures for the APsystems Local API tests."""
from collections.abc import Generator
from unittest.mock import AsyncMock, MagicMock, patch
import pytest
@pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
"""Override async_setup_entry."""
with patch(
"homeassistant.components.apsystems.async_setup_entry",
return_value=True,
) as mock_setup_entry:
yield mock_setup_entry
@pytest.fixture
def mock_apsystems():
"""Override APsystemsEZ1M.get_device_info() to return MY_SERIAL_NUMBER as the serial number."""
ret_data = MagicMock()
ret_data.deviceId = "MY_SERIAL_NUMBER"
with patch(
"homeassistant.components.apsystems.config_flow.APsystemsEZ1M",
return_value=AsyncMock(),
) as mock_api:
mock_api.return_value.get_device_info.return_value = ret_data
yield mock_api