* Remove option flow, refactor and improve the code quality after review in PR #54280 * Remove coordinator.py from coverage report * Some minor improvements for unit tests * Remove _LOGGER * Use pytest.fixture and some more improvments * Add back empty __init__ * Fix docstring --------- Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
33 lines
1,000 B
Python
33 lines
1,000 B
Python
"""Fixtures for Discovergy integration tests."""
|
|
from unittest.mock import AsyncMock, Mock, patch
|
|
|
|
import pytest
|
|
|
|
from homeassistant.components.discovergy import DOMAIN
|
|
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
from tests.common import MockConfigEntry
|
|
from tests.components.discovergy.const import GET_METERS
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_meters() -> Mock:
|
|
"""Patch libraries."""
|
|
with patch("pydiscovergy.Discovergy.get_meters") as discovergy:
|
|
discovergy.side_effect = AsyncMock(return_value=GET_METERS)
|
|
yield discovergy
|
|
|
|
|
|
@pytest.fixture
|
|
async def mock_config_entry(hass: HomeAssistant) -> MockConfigEntry:
|
|
"""Return a MockConfigEntry for testing."""
|
|
entry = MockConfigEntry(
|
|
domain=DOMAIN,
|
|
title="user@example.org",
|
|
unique_id="user@example.org",
|
|
data={CONF_EMAIL: "user@example.org", CONF_PASSWORD: "supersecretpassword"},
|
|
)
|
|
entry.add_to_hass(hass)
|
|
|
|
return entry
|