mirror of
https://github.com/home-assistant/core.git
synced 2026-12-03 12:21:04 -04:00
Patch the PyViCare client instead of integration setup in ViCare tests (#184730)
This commit is contained in:
@@ -15,8 +15,6 @@ from homeassistant.components.application_credentials import (
|
||||
async_import_client_credential,
|
||||
)
|
||||
from homeassistant.components.vicare.const import DOMAIN
|
||||
from homeassistant.components.vicare.types import ViCareData, ViCareDevice
|
||||
from homeassistant.components.vicare.utils import get_device_serial
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
@@ -41,6 +39,9 @@ class MockPyViCare:
|
||||
|
||||
def __init__(self, fixtures: list[Fixture]) -> None:
|
||||
"""Init devices from json dumps, sharing one service per gateway."""
|
||||
self.loadViaGateway = Mock()
|
||||
self.setCacheDuration = Mock()
|
||||
self.initWithExternalOAuth = Mock()
|
||||
self.devices = []
|
||||
self.services: dict[str, MockViCareService] = {}
|
||||
for idx, fixture in enumerate(fixtures):
|
||||
@@ -82,16 +83,6 @@ class MockPyViCare:
|
||||
),
|
||||
]
|
||||
|
||||
def as_vicare_data(self) -> ViCareData:
|
||||
"""Convert to ViCareData as returned by _setup_vicare_api."""
|
||||
devices = []
|
||||
for device in self.devices:
|
||||
api = device.asAutoDetectDevice()
|
||||
devices.append(
|
||||
ViCareDevice(config=device, api=api, serial=get_device_serial(api))
|
||||
)
|
||||
return ViCareData(client=self, devices=devices)
|
||||
|
||||
|
||||
class MockViCareService:
|
||||
"""Mock of the gateway-wide service PyViCare shares in viaGateway mode.
|
||||
@@ -178,10 +169,7 @@ async def mock_vicare_gas_boiler(
|
||||
patch(
|
||||
"homeassistant.helpers.config_entry_oauth2_flow.OAuth2Session.async_ensure_token_valid",
|
||||
),
|
||||
patch(
|
||||
f"{MODULE}._setup_vicare_api",
|
||||
return_value=MockPyViCare(fixtures).as_vicare_data(),
|
||||
),
|
||||
patch(f"{MODULE}.PyViCare", return_value=MockPyViCare(fixtures)),
|
||||
):
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
@@ -201,10 +189,7 @@ async def mock_vicare_room_sensors(
|
||||
patch(
|
||||
"homeassistant.helpers.config_entry_oauth2_flow.OAuth2Session.async_ensure_token_valid",
|
||||
),
|
||||
patch(
|
||||
f"{MODULE}._setup_vicare_api",
|
||||
return_value=MockPyViCare(fixtures).as_vicare_data(),
|
||||
),
|
||||
patch(f"{MODULE}.PyViCare", return_value=MockPyViCare(fixtures)),
|
||||
):
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
|
||||
@@ -56,10 +56,7 @@ async def test_all_entities(
|
||||
patch(
|
||||
"homeassistant.helpers.config_entry_oauth2_flow.OAuth2Session.async_ensure_token_valid",
|
||||
),
|
||||
patch(
|
||||
f"{MODULE}._setup_vicare_api",
|
||||
return_value=MockPyViCare(fixtures).as_vicare_data(),
|
||||
),
|
||||
patch(f"{MODULE}.PyViCare", return_value=MockPyViCare(fixtures)),
|
||||
patch(f"{MODULE}.PLATFORMS", [Platform.BINARY_SENSOR]),
|
||||
):
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
@@ -28,10 +28,7 @@ async def test_all_entities(
|
||||
patch(
|
||||
"homeassistant.helpers.config_entry_oauth2_flow.OAuth2Session.async_ensure_token_valid",
|
||||
),
|
||||
patch(
|
||||
f"{MODULE}._setup_vicare_api",
|
||||
return_value=MockPyViCare(fixtures).as_vicare_data(),
|
||||
),
|
||||
patch(f"{MODULE}.PyViCare", return_value=MockPyViCare(fixtures)),
|
||||
patch(f"{MODULE}.PLATFORMS", [Platform.BUTTON]),
|
||||
):
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
@@ -37,10 +37,7 @@ async def test_all_entities(
|
||||
patch(
|
||||
"homeassistant.helpers.config_entry_oauth2_flow.OAuth2Session.async_ensure_token_valid",
|
||||
),
|
||||
patch(
|
||||
f"{MODULE}._setup_vicare_api",
|
||||
return_value=MockPyViCare(fixtures).as_vicare_data(),
|
||||
),
|
||||
patch(f"{MODULE}.PyViCare", return_value=MockPyViCare(fixtures)),
|
||||
patch(f"{MODULE}.PLATFORMS", [Platform.CLIMATE]),
|
||||
):
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
@@ -90,10 +87,7 @@ async def test_hvac_action_compressor_phase(
|
||||
patch(
|
||||
"homeassistant.helpers.config_entry_oauth2_flow.OAuth2Session.async_ensure_token_valid",
|
||||
),
|
||||
patch(
|
||||
f"{MODULE}._setup_vicare_api",
|
||||
return_value=MockPyViCare(fixtures).as_vicare_data(),
|
||||
),
|
||||
patch(f"{MODULE}.PyViCare", return_value=MockPyViCare(fixtures)),
|
||||
patch(f"{MODULE}.PLATFORMS", [Platform.CLIMATE]),
|
||||
patch(
|
||||
"homeassistant.components.vicare.climate.get_compressors",
|
||||
@@ -146,10 +140,7 @@ async def test_hvac_action_multi_compressor_cooling_takes_precedence(
|
||||
patch(
|
||||
"homeassistant.helpers.config_entry_oauth2_flow.OAuth2Session.async_ensure_token_valid",
|
||||
),
|
||||
patch(
|
||||
f"{MODULE}._setup_vicare_api",
|
||||
return_value=MockPyViCare(fixtures).as_vicare_data(),
|
||||
),
|
||||
patch(f"{MODULE}.PyViCare", return_value=MockPyViCare(fixtures)),
|
||||
patch(f"{MODULE}.PLATFORMS", [Platform.CLIMATE]),
|
||||
patch(
|
||||
"homeassistant.components.vicare.climate.get_compressors",
|
||||
@@ -188,10 +179,7 @@ async def test_hvac_mode_cooling(
|
||||
patch(
|
||||
"homeassistant.helpers.config_entry_oauth2_flow.OAuth2Session.async_ensure_token_valid",
|
||||
),
|
||||
patch(
|
||||
f"{MODULE}._setup_vicare_api",
|
||||
return_value=MockPyViCare(fixtures).as_vicare_data(),
|
||||
),
|
||||
patch(f"{MODULE}.PyViCare", return_value=MockPyViCare(fixtures)),
|
||||
patch(f"{MODULE}.PLATFORMS", [Platform.CLIMATE]),
|
||||
):
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
@@ -71,10 +71,7 @@ async def test_diagnostics_scopes_features_to_their_device(
|
||||
patch(
|
||||
"homeassistant.helpers.config_entry_oauth2_flow.OAuth2Session.async_ensure_token_valid",
|
||||
),
|
||||
patch(
|
||||
f"{MODULE}._setup_vicare_api",
|
||||
return_value=MockPyViCare(fixtures).as_vicare_data(),
|
||||
),
|
||||
patch(f"{MODULE}.PyViCare", return_value=MockPyViCare(fixtures)),
|
||||
):
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
|
||||
@@ -17,6 +17,10 @@ from .conftest import Fixture, MockPyViCare
|
||||
|
||||
from tests.common import MockConfigEntry, snapshot_platform
|
||||
|
||||
GET_QUICKMODE = (
|
||||
"PyViCare.PyViCareVentilationDevice.VentilationDevice.getVentilationQuickmode"
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
||||
async def test_all_entities(
|
||||
@@ -35,10 +39,7 @@ async def test_all_entities(
|
||||
patch(
|
||||
"homeassistant.helpers.config_entry_oauth2_flow.OAuth2Session.async_ensure_token_valid",
|
||||
),
|
||||
patch(
|
||||
f"{MODULE}._setup_vicare_api",
|
||||
return_value=MockPyViCare(fixtures).as_vicare_data(),
|
||||
),
|
||||
patch(f"{MODULE}.PyViCare", return_value=MockPyViCare(fixtures)),
|
||||
patch(f"{MODULE}.PLATFORMS", [Platform.FAN]),
|
||||
):
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
@@ -60,16 +61,14 @@ async def test_standby_quickmode(
|
||||
difference here.
|
||||
"""
|
||||
fixtures: list[Fixture] = [Fixture({"type:ventilation"}, "vicare/VitoPure.json")]
|
||||
vicare_data = MockPyViCare(fixtures).as_vicare_data()
|
||||
api = vicare_data.devices[0].api
|
||||
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.helpers.config_entry_oauth2_flow.OAuth2Session.async_ensure_token_valid",
|
||||
),
|
||||
patch(f"{MODULE}._setup_vicare_api", return_value=vicare_data),
|
||||
patch(f"{MODULE}.PyViCare", return_value=MockPyViCare(fixtures)),
|
||||
patch(f"{MODULE}.PLATFORMS", [Platform.FAN]),
|
||||
patch.object(api, "getVentilationQuickmode", return_value=True),
|
||||
patch(GET_QUICKMODE, return_value=True),
|
||||
):
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
@@ -82,13 +81,12 @@ async def test_standby_quickmode(
|
||||
await async_update_entity(hass, entity_id)
|
||||
assert hass.states.get(entity_id).attributes[ATTR_ICON] == "mdi:fan-auto"
|
||||
|
||||
with patch.object(api, "getVentilationQuickmode", return_value=True):
|
||||
with patch(GET_QUICKMODE, return_value=True):
|
||||
await async_update_entity(hass, entity_id)
|
||||
assert hass.states.get(entity_id).attributes[ATTR_ICON] == "mdi:fan-off"
|
||||
|
||||
with patch.object(
|
||||
api,
|
||||
"getVentilationQuickmode",
|
||||
with patch(
|
||||
GET_QUICKMODE,
|
||||
side_effect=PyViCareNotSupportedFeatureError("standby"),
|
||||
):
|
||||
await async_update_entity(hass, entity_id)
|
||||
@@ -105,16 +103,14 @@ async def test_standby_quickmode_with_a_second_fan(
|
||||
Fixture({"type:ventilation"}, "vicare/VitoPure.json"),
|
||||
Fixture({"type:ventilation"}, "vicare/ViAir300F.json"),
|
||||
]
|
||||
vicare_data = MockPyViCare(fixtures).as_vicare_data()
|
||||
api = vicare_data.devices[0].api
|
||||
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.helpers.config_entry_oauth2_flow.OAuth2Session.async_ensure_token_valid",
|
||||
),
|
||||
patch(f"{MODULE}._setup_vicare_api", return_value=vicare_data),
|
||||
patch(f"{MODULE}.PyViCare", return_value=MockPyViCare(fixtures)),
|
||||
patch(f"{MODULE}.PLATFORMS", [Platform.FAN]),
|
||||
patch.object(api, "getVentilationQuickmode", return_value=True),
|
||||
patch(GET_QUICKMODE, return_value=True),
|
||||
):
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
|
||||
@@ -333,10 +333,7 @@ async def test_coordinator_backs_off_until_the_quota_resets(
|
||||
patch(
|
||||
"homeassistant.helpers.config_entry_oauth2_flow.OAuth2Session.async_ensure_token_valid",
|
||||
),
|
||||
patch(
|
||||
f"{MODULE}._setup_vicare_api",
|
||||
return_value=mock_vicare.as_vicare_data(),
|
||||
),
|
||||
patch(f"{MODULE}.PyViCare", return_value=mock_vicare),
|
||||
):
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
@@ -384,10 +381,7 @@ async def test_coordinator_backs_off_when_the_reset_has_passed(
|
||||
patch(
|
||||
"homeassistant.helpers.config_entry_oauth2_flow.OAuth2Session.async_ensure_token_valid",
|
||||
),
|
||||
patch(
|
||||
f"{MODULE}._setup_vicare_api",
|
||||
return_value=mock_vicare.as_vicare_data(),
|
||||
),
|
||||
patch(f"{MODULE}.PyViCare", return_value=mock_vicare),
|
||||
):
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
@@ -426,15 +420,14 @@ async def test_setup_entry_invalid_credentials(
|
||||
) -> None:
|
||||
"""Test setup raises ConfigEntryAuthFailed on PyViCare credentials error."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
client = MockPyViCare([])
|
||||
client.initWithExternalOAuth.side_effect = PyViCareInvalidCredentialsError
|
||||
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.helpers.config_entry_oauth2_flow.OAuth2Session.async_ensure_token_valid",
|
||||
),
|
||||
patch(
|
||||
f"{MODULE}._setup_vicare_api",
|
||||
side_effect=PyViCareInvalidCredentialsError,
|
||||
),
|
||||
patch(f"{MODULE}.PyViCare", return_value=client),
|
||||
):
|
||||
await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
@@ -458,20 +451,19 @@ async def test_setup_entry_rate_limited(
|
||||
}
|
||||
}
|
||||
)
|
||||
client = MockPyViCare([])
|
||||
client.initWithExternalOAuth.side_effect = rate_limit_error
|
||||
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.helpers.config_entry_oauth2_flow.OAuth2Session.async_ensure_token_valid",
|
||||
),
|
||||
patch(
|
||||
f"{MODULE}._setup_vicare_api",
|
||||
side_effect=rate_limit_error,
|
||||
) as setup_api,
|
||||
patch(f"{MODULE}.PyViCare", return_value=client),
|
||||
):
|
||||
await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
setup_api.assert_called_once()
|
||||
client.initWithExternalOAuth.assert_called_once()
|
||||
assert mock_config_entry.state is ConfigEntryState.SETUP_RETRY
|
||||
# SETUP_RETRY alone would also match an unrelated ConfigEntryNotReady.
|
||||
assert "rate limit" in mock_config_entry.reason
|
||||
@@ -521,15 +513,14 @@ async def test_setup_entry_invalid_configuration(
|
||||
) -> None:
|
||||
"""Test setup raises ConfigEntryAuthFailed on PyViCare config error."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
client = MockPyViCare([])
|
||||
client.initWithExternalOAuth.side_effect = PyViCareInvalidConfigurationError
|
||||
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.helpers.config_entry_oauth2_flow.OAuth2Session.async_ensure_token_valid",
|
||||
),
|
||||
patch(
|
||||
f"{MODULE}._setup_vicare_api",
|
||||
side_effect=PyViCareInvalidConfigurationError,
|
||||
),
|
||||
patch(f"{MODULE}.PyViCare", return_value=client),
|
||||
):
|
||||
await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
@@ -553,10 +544,7 @@ async def test_device_and_entity_migration(
|
||||
patch(
|
||||
"homeassistant.helpers.config_entry_oauth2_flow.OAuth2Session.async_ensure_token_valid",
|
||||
),
|
||||
patch(
|
||||
f"{MODULE}._setup_vicare_api",
|
||||
return_value=MockPyViCare(fixtures).as_vicare_data(),
|
||||
),
|
||||
patch(f"{MODULE}.PyViCare", return_value=MockPyViCare(fixtures)),
|
||||
patch(f"{MODULE}.PLATFORMS", [Platform.CLIMATE]),
|
||||
):
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
@@ -651,10 +639,7 @@ async def test_coordinator_recovers_after_transient_failure(
|
||||
patch(
|
||||
"homeassistant.helpers.config_entry_oauth2_flow.OAuth2Session.async_ensure_token_valid",
|
||||
),
|
||||
patch(
|
||||
f"{MODULE}._setup_vicare_api",
|
||||
return_value=mock_vicare.as_vicare_data(),
|
||||
),
|
||||
patch(f"{MODULE}.PyViCare", return_value=mock_vicare),
|
||||
patch(f"{MODULE}.PLATFORMS", [Platform.SENSOR]),
|
||||
):
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
@@ -705,10 +690,7 @@ async def test_coordinator_handles_invalid_data(
|
||||
patch(
|
||||
"homeassistant.helpers.config_entry_oauth2_flow.OAuth2Session.async_ensure_token_valid",
|
||||
),
|
||||
patch(
|
||||
f"{MODULE}._setup_vicare_api",
|
||||
return_value=mock_vicare.as_vicare_data(),
|
||||
),
|
||||
patch(f"{MODULE}.PyViCare", return_value=mock_vicare),
|
||||
patch(f"{MODULE}.PLATFORMS", [Platform.SENSOR]),
|
||||
):
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
@@ -745,10 +727,7 @@ async def test_per_gateway_failure_isolation(
|
||||
patch(
|
||||
"homeassistant.helpers.config_entry_oauth2_flow.OAuth2Session.async_ensure_token_valid",
|
||||
),
|
||||
patch(
|
||||
f"{MODULE}._setup_vicare_api",
|
||||
return_value=mock_vicare.as_vicare_data(),
|
||||
),
|
||||
patch(f"{MODULE}.PyViCare", return_value=mock_vicare),
|
||||
patch(f"{MODULE}.PLATFORMS", [Platform.SENSOR]),
|
||||
):
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
@@ -798,10 +777,7 @@ async def test_devices_on_same_gateway_share_coordinator(
|
||||
patch(
|
||||
"homeassistant.helpers.config_entry_oauth2_flow.OAuth2Session.async_ensure_token_valid",
|
||||
),
|
||||
patch(
|
||||
f"{MODULE}._setup_vicare_api",
|
||||
return_value=mock_vicare.as_vicare_data(),
|
||||
),
|
||||
patch(f"{MODULE}.PyViCare", return_value=mock_vicare),
|
||||
patch(f"{MODULE}.PLATFORMS", [Platform.SENSOR]),
|
||||
):
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
@@ -845,10 +821,7 @@ async def test_coordinator_auth_failure_triggers_reauth(
|
||||
patch(
|
||||
"homeassistant.helpers.config_entry_oauth2_flow.OAuth2Session.async_ensure_token_valid",
|
||||
),
|
||||
patch(
|
||||
f"{MODULE}._setup_vicare_api",
|
||||
return_value=mock_vicare.as_vicare_data(),
|
||||
),
|
||||
patch(f"{MODULE}.PyViCare", return_value=mock_vicare),
|
||||
patch(f"{MODULE}.PLATFORMS", [Platform.SENSOR]),
|
||||
):
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
@@ -890,10 +863,7 @@ async def test_device_via_device_links(
|
||||
patch(
|
||||
"homeassistant.helpers.config_entry_oauth2_flow.OAuth2Session.async_ensure_token_valid",
|
||||
),
|
||||
patch(
|
||||
f"{MODULE}._setup_vicare_api",
|
||||
return_value=MockPyViCare(fixtures).as_vicare_data(),
|
||||
),
|
||||
patch(f"{MODULE}.PyViCare", return_value=MockPyViCare(fixtures)),
|
||||
):
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
@@ -922,10 +892,7 @@ async def test_device_via_device_missing_gateway(
|
||||
patch(
|
||||
"homeassistant.helpers.config_entry_oauth2_flow.OAuth2Session.async_ensure_token_valid",
|
||||
),
|
||||
patch(
|
||||
f"{MODULE}._setup_vicare_api",
|
||||
return_value=MockPyViCare(fixtures).as_vicare_data(),
|
||||
),
|
||||
patch(f"{MODULE}.PyViCare", return_value=MockPyViCare(fixtures)),
|
||||
):
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
@@ -940,11 +907,7 @@ async def test_setup_runs_pyvicare_init_and_fetches_once_per_gateway(
|
||||
hass: HomeAssistant,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Set up through _setup_vicare_api instead of a prebuilt ViCareData.
|
||||
|
||||
Covers the via-gateway init, the gateway-based cache duration, and one
|
||||
fetch per gateway.
|
||||
"""
|
||||
"""Test the via-gateway init, the cache duration and one fetch per gateway."""
|
||||
# Two devices behind gwA, one behind gwB: two gateways, three devices.
|
||||
fixtures: list[Fixture] = [
|
||||
Fixture({"type:climateSensor"}, "vicare/RoomSensor1.json", gateway_id="gwA"),
|
||||
@@ -954,11 +917,8 @@ async def test_setup_runs_pyvicare_init_and_fetches_once_per_gateway(
|
||||
client = MockPyViCare(fixtures)
|
||||
# viaGateway has to be set before init, the services are wired during init.
|
||||
setup_calls: list[str] = []
|
||||
client.loadViaGateway = Mock(side_effect=lambda _: setup_calls.append("gateway"))
|
||||
client.setCacheDuration = Mock()
|
||||
client.initWithExternalOAuth = Mock(
|
||||
side_effect=lambda _: setup_calls.append("init")
|
||||
)
|
||||
client.loadViaGateway.side_effect = lambda _: setup_calls.append("gateway")
|
||||
client.initWithExternalOAuth.side_effect = lambda _: setup_calls.append("init")
|
||||
|
||||
with (
|
||||
patch(
|
||||
@@ -1003,9 +963,6 @@ async def test_offline_gateway_does_not_stretch_the_cache(
|
||||
),
|
||||
]
|
||||
client = MockPyViCare(fixtures)
|
||||
client.loadViaGateway = Mock()
|
||||
client.setCacheDuration = Mock()
|
||||
client.initWithExternalOAuth = Mock()
|
||||
|
||||
with (
|
||||
patch(
|
||||
@@ -1038,9 +995,6 @@ async def test_setup_retries_until_a_device_is_online(
|
||||
Fixture({"type:boiler"}, "vicare/Vitodens300W.json", online=False)
|
||||
]
|
||||
client = MockPyViCare(fixtures)
|
||||
client.loadViaGateway = Mock()
|
||||
client.setCacheDuration = Mock()
|
||||
client.initWithExternalOAuth = Mock()
|
||||
|
||||
with (
|
||||
patch(
|
||||
@@ -1084,10 +1038,7 @@ async def test_setup_loads_with_unpaid_package_gateway(
|
||||
patch(
|
||||
"homeassistant.helpers.config_entry_oauth2_flow.OAuth2Session.async_ensure_token_valid",
|
||||
),
|
||||
patch(
|
||||
f"{MODULE}._setup_vicare_api",
|
||||
return_value=mock_vicare.as_vicare_data(),
|
||||
),
|
||||
patch(f"{MODULE}.PyViCare", return_value=mock_vicare),
|
||||
patch(f"{MODULE}.PLATFORMS", [Platform.SENSOR]),
|
||||
):
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
|
||||
@@ -28,10 +28,7 @@ async def test_all_entities(
|
||||
patch(
|
||||
"homeassistant.helpers.config_entry_oauth2_flow.OAuth2Session.async_ensure_token_valid",
|
||||
),
|
||||
patch(
|
||||
f"{MODULE}._setup_vicare_api",
|
||||
return_value=MockPyViCare(fixtures).as_vicare_data(),
|
||||
),
|
||||
patch(f"{MODULE}.PyViCare", return_value=MockPyViCare(fixtures)),
|
||||
patch(f"{MODULE}.PLATFORMS", [Platform.NUMBER]),
|
||||
):
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
@@ -30,10 +30,7 @@ async def test_all_entities(
|
||||
patch(
|
||||
"homeassistant.helpers.config_entry_oauth2_flow.OAuth2Session.async_ensure_token_valid",
|
||||
),
|
||||
patch(
|
||||
f"{MODULE}._setup_vicare_api",
|
||||
return_value=MockPyViCare(fixtures).as_vicare_data(),
|
||||
),
|
||||
patch(f"{MODULE}.PyViCare", return_value=MockPyViCare(fixtures)),
|
||||
patch(f"{MODULE}.PLATFORMS", [Platform.SELECT]),
|
||||
):
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
@@ -56,10 +56,7 @@ async def test_all_entities(
|
||||
patch(
|
||||
"homeassistant.helpers.config_entry_oauth2_flow.OAuth2Session.async_ensure_token_valid",
|
||||
),
|
||||
patch(
|
||||
f"{MODULE}._setup_vicare_api",
|
||||
return_value=MockPyViCare(fixtures).as_vicare_data(),
|
||||
),
|
||||
patch(f"{MODULE}.PyViCare", return_value=MockPyViCare(fixtures)),
|
||||
patch(f"{MODULE}.PLATFORMS", [Platform.SENSOR]),
|
||||
):
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
@@ -108,10 +105,7 @@ async def test_no_api_read_on_event_loop(
|
||||
patch(
|
||||
"homeassistant.helpers.config_entry_oauth2_flow.OAuth2Session.async_ensure_token_valid",
|
||||
),
|
||||
patch(
|
||||
f"{MODULE}._setup_vicare_api",
|
||||
return_value=mock_vicare.as_vicare_data(),
|
||||
),
|
||||
patch(f"{MODULE}.PyViCare", return_value=mock_vicare),
|
||||
patch(f"{MODULE}.PLATFORMS", [Platform.SENSOR, Platform.FAN]),
|
||||
):
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
@@ -44,10 +44,7 @@ async def setup_switch_platform(
|
||||
patch(
|
||||
"homeassistant.helpers.config_entry_oauth2_flow.OAuth2Session.async_ensure_token_valid",
|
||||
),
|
||||
patch(
|
||||
f"{MODULE}._setup_vicare_api",
|
||||
return_value=mock_vicare.as_vicare_data(),
|
||||
),
|
||||
patch(f"{MODULE}.PyViCare", return_value=mock_vicare),
|
||||
patch(f"{MODULE}.PLATFORMS", [Platform.SWITCH]),
|
||||
):
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
@@ -31,10 +31,7 @@ async def test_all_entities(
|
||||
patch(
|
||||
"homeassistant.helpers.config_entry_oauth2_flow.OAuth2Session.async_ensure_token_valid",
|
||||
),
|
||||
patch(
|
||||
f"{MODULE}._setup_vicare_api",
|
||||
return_value=MockPyViCare(fixtures).as_vicare_data(),
|
||||
),
|
||||
patch(f"{MODULE}.PyViCare", return_value=MockPyViCare(fixtures)),
|
||||
patch(f"{MODULE}.PLATFORMS", [Platform.WATER_HEATER]),
|
||||
):
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
@@ -53,10 +50,7 @@ async def test_dhw_active_state(
|
||||
patch(
|
||||
"homeassistant.helpers.config_entry_oauth2_flow.OAuth2Session.async_ensure_token_valid",
|
||||
),
|
||||
patch(
|
||||
f"{MODULE}._setup_vicare_api",
|
||||
return_value=MockPyViCare(fixtures).as_vicare_data(),
|
||||
),
|
||||
patch(f"{MODULE}.PyViCare", return_value=MockPyViCare(fixtures)),
|
||||
patch(f"{MODULE}.PLATFORMS", [Platform.WATER_HEATER]),
|
||||
):
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
Reference in New Issue
Block a user