diff --git a/tests/components/vicare/conftest.py b/tests/components/vicare/conftest.py index af731b2ea035..289db28dc334 100644 --- a/tests/components/vicare/conftest.py +++ b/tests/components/vicare/conftest.py @@ -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) diff --git a/tests/components/vicare/test_binary_sensor.py b/tests/components/vicare/test_binary_sensor.py index 61622ee6cebc..a9d17801e3ea 100644 --- a/tests/components/vicare/test_binary_sensor.py +++ b/tests/components/vicare/test_binary_sensor.py @@ -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) diff --git a/tests/components/vicare/test_button.py b/tests/components/vicare/test_button.py index e11a5b17d3bd..d57cd62ff0a2 100644 --- a/tests/components/vicare/test_button.py +++ b/tests/components/vicare/test_button.py @@ -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) diff --git a/tests/components/vicare/test_climate.py b/tests/components/vicare/test_climate.py index 6b903cfe3398..19af0466fbaa 100644 --- a/tests/components/vicare/test_climate.py +++ b/tests/components/vicare/test_climate.py @@ -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) diff --git a/tests/components/vicare/test_diagnostics.py b/tests/components/vicare/test_diagnostics.py index 3dc22ac2ad9c..ffa62916f9f8 100644 --- a/tests/components/vicare/test_diagnostics.py +++ b/tests/components/vicare/test_diagnostics.py @@ -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) diff --git a/tests/components/vicare/test_fan.py b/tests/components/vicare/test_fan.py index 2d89c454927c..4096fac20fe5 100644 --- a/tests/components/vicare/test_fan.py +++ b/tests/components/vicare/test_fan.py @@ -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) diff --git a/tests/components/vicare/test_init.py b/tests/components/vicare/test_init.py index cdf1e3929305..ab144b4f779f 100644 --- a/tests/components/vicare/test_init.py +++ b/tests/components/vicare/test_init.py @@ -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) diff --git a/tests/components/vicare/test_number.py b/tests/components/vicare/test_number.py index 83471943edd8..0afcf138d363 100644 --- a/tests/components/vicare/test_number.py +++ b/tests/components/vicare/test_number.py @@ -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) diff --git a/tests/components/vicare/test_select.py b/tests/components/vicare/test_select.py index 5540ecb642ba..e57cc157aa7e 100644 --- a/tests/components/vicare/test_select.py +++ b/tests/components/vicare/test_select.py @@ -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) diff --git a/tests/components/vicare/test_sensor.py b/tests/components/vicare/test_sensor.py index 99bab0689f8a..49940b9a379b 100644 --- a/tests/components/vicare/test_sensor.py +++ b/tests/components/vicare/test_sensor.py @@ -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) diff --git a/tests/components/vicare/test_switch.py b/tests/components/vicare/test_switch.py index 24e3b6c80478..b9fbd545f6c4 100644 --- a/tests/components/vicare/test_switch.py +++ b/tests/components/vicare/test_switch.py @@ -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) diff --git a/tests/components/vicare/test_water_heater.py b/tests/components/vicare/test_water_heater.py index 873a9f2af821..8d371d48e63a 100644 --- a/tests/components/vicare/test_water_heater.py +++ b/tests/components/vicare/test_water_heater.py @@ -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)