Add support for HomeWizard enable/disable cloud feature (#82573)

This commit is contained in:
Duco Sebel 2022-11-27 20:26:15 +01:00 committed by GitHub
parent 093bd00807
commit 27bd1520e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 148 additions and 11 deletions

View file

@ -2,7 +2,8 @@
import json
from unittest.mock import AsyncMock, patch
from homewizard_energy.models import Data, Device, State
from homewizard_energy.features import Features
from homewizard_energy.models import Data, Device, State, System
import pytest
from homeassistant.components.homewizard.const import DOMAIN
@ -37,26 +38,32 @@ def mock_config_entry() -> MockConfigEntry:
@pytest.fixture
def mock_homewizardenergy():
"""Return a mocked P1 meter."""
"""Return a mocked all-feature device."""
with patch(
"homeassistant.components.homewizard.coordinator.HomeWizardEnergy",
) as device:
client = device.return_value
client.features = AsyncMock(return_value=Features("HWE-SKT", "3.01"))
client.device = AsyncMock(
return_value=Device.from_dict(
side_effect=lambda: Device.from_dict(
json.loads(load_fixture("homewizard/device.json"))
)
)
client.data = AsyncMock(
return_value=Data.from_dict(
side_effect=lambda: Data.from_dict(
json.loads(load_fixture("homewizard/data.json"))
)
)
client.state = AsyncMock(
return_value=State.from_dict(
side_effect=lambda: State.from_dict(
json.loads(load_fixture("homewizard/state.json"))
)
)
client.system = AsyncMock(
side_effect=lambda: System.from_dict(
json.loads(load_fixture("homewizard/system.json"))
)
)
yield device