  def testCreateVolumeCopy3(self,
                            mock_list_instances,
                            mock_list_volumes,
                            mock_loader):
    """Test that a volume is correctly cloned."""
    mock_loader.return_value = None
    # Should raise a ValueError exception  as no volume_id or instance_id is
    # specified.
    with self.assertRaises(ValueError):
      forensics.CreateVolumeCopy(aws_mocks.FAKE_INSTANCE.availability_zone)

    # Should raise a ResourceCreationError as we are querying a non-existent
    # instance.
    mock_list_instances.return_value = {}
    with self.assertRaises(errors.ResourceCreationError):
      forensics.CreateVolumeCopy(
          aws_mocks.FAKE_INSTANCE.availability_zone,
          instance_id='non-existent-instance-id')

    # Should raise a ResourceCreationError as we are querying a non-existent
    # volume.
    mock_list_volumes.return_value = {}
    with self.assertRaises(errors.ResourceCreationError):
      forensics.CreateVolumeCopy(
          aws_mocks.FAKE_INSTANCE.availability_zone,
          volume_id='non-existent-volume-id')
Test that a volume is correctly cloned.
tests/providers/aws/test_forensics.py