  def testCreateInstanceFromArgumentsError(self,
      mock_create_from_request, mock_get_machine_type,
      mock_get_disk_type, mock_get_image_family, mock_gce_api):
    """Test creating compute instance while loading boot disk fails."""
    mock_create_from_request.return_value = gcp_mocks.FAKE_INSTANCE
    mock_get_machine_type.return_value = gcp_mocks.MOCK_MACHINE_TYPES
    mock_get_disk_type.return_value = gcp_mocks.MOCK_DISK_TYPES
    mock_get_image_family.return_value = gcp_mocks.MOCK_COMPUTE_IMAGE

    mock_gce_api.return_value.disks.return_value.get.return_value.execute.side_effect = HttpError(
        resp=mock.Mock(status=404), content=b'No compute disk')
    with self.assertRaises(errors.ResourceNotFoundError) as context:
      _ = gcp_mocks.FAKE_ANALYSIS_PROJECT.compute.CreateInstanceFromArguments(
        gcp_mocks.FAKE_INSTANCE.name, 'e2-medium', 'us-central1-a',
        boot_disk=gcp_mocks.FAKE_BOOT_DISK)
    msg = ('No compute disk {0:s} found in project {1:s} in zone '
          '{2:s}').format(
                gcp_mocks.FAKE_BOOT_DISK.name,
                gcp_mocks.FAKE_ANALYSIS_PROJECT.project_id,
                'us-central1-a')
    self.assertIn(msg, str(context.exception))

    mock_gce_api.return_value.disks.return_value.get.return_value.execute.side_effect = HttpError(
        resp=mock.Mock(status=400), content=b'Error while getting')
    with self.assertRaises(errors.OperationFailedError) as context:
      _ = gcp_mocks.FAKE_ANALYSIS_PROJECT.compute.CreateInstanceFromArguments(
        gcp_mocks.FAKE_INSTANCE.name, 'e2-medium', 'us-central1-a',
        boot_disk=gcp_mocks.FAKE_BOOT_DISK)
    msg = 'Error while getting {0:s}'.format(gcp_mocks.FAKE_BOOT_DISK.name)
    self.assertIn(msg, str(context.exception))
Test creating compute instance while loading boot disk fails.
tests/providers/gcp/internal/test_compute.py