Beispiel #1
0
    def test_copy_ami(self):
        """Test that an image is copied via the boto session successfully."""
        mock_session = Mock()
        mock_ec2_client = mock_session.client.return_value
        mock_original_image = Mock()
        mock_copied_image_dict = helper.generate_mock_image_dict()
        mock_ec2_client.copy_image.return_value = mock_copied_image_dict

        image_id = mock_original_image.id
        source_region = random.choice(helper.SOME_AWS_REGIONS)
        with patch.object(ec2, 'get_ami') as mock_get_ami:
            mock_get_ami.return_value = mock_original_image
            result = ec2.copy_ami(mock_session, image_id, source_region)

        mock_ec2_client.copy_image.assert_called_once()
        mock_ec2_client.create_tags.assert_called_once()
        self.assertEqual(result, mock_copied_image_dict['ImageId'])
Beispiel #2
0
 def test_generate_mock_image_dict_with_args(self):
     """Assert generation of an image-like dict with specified arguments."""
     image_id = helper.generate_dummy_image_id()
     image_dict = helper.generate_mock_image_dict(image_id)
     self.assertEqual(image_dict["ImageId"], image_id)
Beispiel #3
0
 def test_generate_mock_image_dict(self):
     """Assert generation of an image-like dict."""
     image_dict = helper.generate_mock_image_dict()
     self.assertIn("ImageId", image_dict)