1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Add LaMetric integration init tests (#78679)

This commit is contained in:
Franck Nijhof
2022-09-19 11:11:05 +02:00
committed by GitHub
parent b5c1f856e2
commit 36eda3801d
3 changed files with 87 additions and 2 deletions

View File

@@ -79,3 +79,18 @@ def mock_lametric_cloud_config_flow() -> Generator[MagicMock, None, None]:
list[CloudDevice], load_fixture("cloud_devices.json", DOMAIN)
)
yield lametric
@pytest.fixture
def mock_lametric() -> Generator[MagicMock, None, None]:
"""Return a mocked LaMetric client."""
with patch(
"homeassistant.components.lametric.coordinator.LaMetricDevice", autospec=True
) as lametric_mock:
lametric = lametric_mock.return_value
lametric.api_key = "mock-api-key"
lametric.host = "127.0.0.1"
lametric.device.return_value = Device.parse_raw(
load_fixture("device.json", DOMAIN)
)
yield lametric