コード例 #1
0
 def test_check_image_state_mystery_load_failure(self):
     """Assert raised exception when image loading fails mysteriously."""
     error_response = {
         "Error": {
             "Code": "itisamystery.gif",
         }
     }
     exception = ClientError(error_response, Mock())
     mock_image = helper.generate_mock_image()
     mock_image.load.side_effect = exception
     with self.assertRaises(ClientError):
         ec2.check_image_state(mock_image)
コード例 #2
0
 def test_check_image_state_not_found(self):
     """Assert raised exception when image is not found."""
     # Dummy response inspired by real exception recorded at
     # https://sentry.io/organizations/cloudigrade/issues/970892568/
     error_response = {
         "Error": {
             "Code": "InvalidAMIID.NotFound",
             "Message": "The image id '[POTATO]' does not exist",
         }
     }
     exception = ClientError(error_response, Mock())
     mock_image = helper.generate_mock_image()
     mock_image.load.side_effect = exception
     with self.assertRaises(AwsImageError):
         ec2.check_image_state(mock_image)
コード例 #3
0
ファイル: test_aws_ec2.py プロジェクト: Nanyte25/cloudigrade
 def test_check_image_state_unhandled(self):
     """Assert raised exception when image state is unhandled."""
     mock_image = helper.generate_mock_image(state='itisamystery.gif')
     with self.assertRaises(ImageNotReadyException):
         ec2.check_image_state(mock_image)
コード例 #4
0
ファイル: test_aws_ec2.py プロジェクト: Nanyte25/cloudigrade
 def test_check_image_state_failed(self):
     """Assert raised exception when image state is failed."""
     mock_image = helper.generate_mock_image(state='failed')
     with self.assertRaises(AwsImageError):
         ec2.check_image_state(mock_image)
コード例 #5
0
ファイル: test_aws_ec2.py プロジェクト: Nanyte25/cloudigrade
 def test_check_image_state_available(self):
     """Assert clean return when image state is available."""
     mock_image = helper.generate_mock_image(state='available')
     ec2.check_image_state(mock_image)
コード例 #6
0
 def test_check_image_state_no_meta(self):
     """Assert raised exception when image has no metadata."""
     mock_image = helper.generate_mock_image()
     mock_image.meta.data = None
     with self.assertRaises(AwsImageError):
         ec2.check_image_state(mock_image)