@mock.patch.object(rest_client.KioxiaProvisioner, 'get_backend_by_id')
@mock.patch.object(rest_client.KioxiaProvisioner, 'get_targets')
@mock.patch.object(rest_client.KioxiaProvisioner, 'get_volumes_by_uuid')
@mock.patch.object(rest_client.KioxiaProvisioner, 'publish')
@mock.patch.object(rest_client.KioxiaProvisioner, 'host_probe')
def test_initialize_connection_backend_exception(self, mock_host_probe, mock_publish, mock_get_volumes_by_uuid, mock_get_targets, mock_get_backend_by_id):
    testvol = _stub_volume()
    testconn = _stub_connector()
    prov_target = TargetEntity('target.nqn', prov_backend1)
    prov_targets_response = entities.ProvisionerResponse([prov_target])
    mock_publish.return_value = success_prov_response
    mock_host_probe.return_value = success_prov_response
    mock_get_volumes_by_uuid.return_value = prov_volumes_response
    mock_get_targets.return_value = prov_targets_response
    mock_get_backend_by_id.side_effect = Exception()
    self.assertRaises(exception.VolumeBackendAPIException, self.driver.initialize_connection, testvol, testconn)
@mock.patch.object(rest_client.KioxiaProvisioner, 'get_backend_by_id')
@mock.patch.object(rest_client.KioxiaProvisioner, 'get_targets')
@mock.patch.object(rest_client.KioxiaProvisioner, 'get_volumes_by_uuid')
@mock.patch.object(rest_client.KioxiaProvisioner, 'publish')
@mock.patch.object(rest_client.KioxiaProvisioner, 'host_probe')
def test_initialize_connection_backend_exception(self, mock_host_probe, mock_publish, mock_get_volumes_by_uuid, mock_get_targets, mock_get_backend_by_id):
    testvol = _stub_volume()
    testconn = _stub_connector()
    prov_target = TargetEntity('target.nqn', prov_backend1)
    prov_targets_response = entities.ProvisionerResponse([prov_target])
    mock_publish.return_value = success_prov_response
    mock_host_probe.return_value = success_prov_response
    mock_get_volumes_by_uuid.return_value = prov_volumes_response
    mock_get_targets.return_value = prov_targets_response
    mock_get_backend_by_id.side_effect = Exception()
    self.assertRaises(exception.VolumeBackendAPIException, self.driver.initialize_connection, testvol, testconn)