async def test_sensor_access_denied(hass): """Test for Renault sensors with access denied failure.""" await async_setup_component(hass, "persistent_notification", {}) entity_registry = mock_registry(hass) device_registry = mock_device_registry(hass) access_denied_exception = exceptions.AccessDeniedException( "err.func.403", "Access is denied for this resource", ) vehicle_proxy = await create_vehicle_proxy_with_side_effect( hass, "zoe_40", access_denied_exception) with patch( "homeassistant.components.renault.RenaultHub.vehicles", new_callable=PropertyMock, return_value={ vehicle_proxy.details.vin: vehicle_proxy, }, ), patch("homeassistant.components.renault.PLATFORMS", [SENSOR_DOMAIN]): await setup_renault_integration(hass) await hass.async_block_till_done() assert len(device_registry.devices) == 0 assert len(entity_registry.entities) == 0
def patch_fixtures_with_access_denied_exception(): """Mock fixtures.""" access_denied_exception = exceptions.AccessDeniedException( "err.func.403", "Access is denied for this resource", ) with _patch_fixtures_with_side_effect(access_denied_exception): yield
async def test_select_access_denied(hass: HomeAssistant): """Test for Renault selects with access denied failure.""" await async_setup_component(hass, "persistent_notification", {}) entity_registry = mock_registry(hass) device_registry = mock_device_registry(hass) vehicle_type = "zoe_40" access_denied_exception = exceptions.AccessDeniedException( "err.func.403", "Access is denied for this resource", ) with patch("homeassistant.components.renault.PLATFORMS", [SELECT_DOMAIN]): await setup_renault_integration_vehicle_with_side_effect( hass, vehicle_type, access_denied_exception) await hass.async_block_till_done() mock_vehicle = MOCK_VEHICLES[vehicle_type] check_device_registry(device_registry, mock_vehicle["expected_device"]) assert len(entity_registry.entities) == 0