Skip to content
Permalink
Browse files
Improve images test
  • Loading branch information
imduffy15 committed Mar 1, 2014
1 parent 507f7c7 commit 1a3c41acdf01e04292c09a35fc3e81f8b3533296
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
@@ -0,0 +1,5 @@
{
"listtemplatesresponse": {
"template": {}
}
}
@@ -9,7 +9,7 @@

class ImagesTestCase(Ec2StackAppTestCase):

def test_describe_images(self):
def test_describe_image(self):
data = self.get_example_data()
data['Action'] = 'DescribeImages'
data['Signature'] = generate_signature(data, 'POST', 'localhost')
@@ -29,7 +29,7 @@ def test_describe_images(self):
self.assert_ok(response)
assert 'DescribeImagesResponse' in response.data

def test_describe_specific_images(self):
def test_describe_image_by_id(self):
data = self.get_example_data()
data['Action'] = 'DescribeImages'
data['ImageId.1'] = 'a32d70ee-95e4-11e3-b2e4-d19c9d3e5e1d'
@@ -49,6 +49,49 @@ def test_describe_specific_images(self):

self.assert_ok(response)
assert 'DescribeImagesResponse' in response.data
assert 'a32d70ee-95e4-11e3-b2e4-d19c9d3e5e1d' in response.data

def test_invalid_describe_image_by_id(self):
data = self.get_example_data()
data['Action'] = 'DescribeImages'
data['ImageId.1'] = 'invalid-image-id'
data['Signature'] = generate_signature(data, 'POST', 'localhost')

get = mock.Mock()
get.return_value.text = read_file(
'tests/data/valid_describe_images.json'
)
get.return_value.status_code = 200

with mock.patch('requests.get', get):
response = self.post(
'/',
data=data
)

self.assert_bad_request(response)
assert 'InvalidAMIID.NotFound' in response.data

def test_empty_response_describe_images_by_id(self):
data = self.get_example_data()
data['Action'] = 'DescribeImages'
data['InstanceId.1'] = 'invalid-images-id'
data['Signature'] = generate_signature(data, 'POST', 'localhost')

get = mock.Mock()
get.return_value.text = read_file(
'tests/data/empty_describe_images.json'
)
get.return_value.status_code = 200

with mock.patch('requests.get', get):
response = self.post(
'/',
data=data
)

self.assert_bad_request(response)
assert 'InvalidAMIID.NotFound' in response.data

def test_describe_image_attribute(self):
data = self.get_example_data()

0 comments on commit 1a3c41a

Please sign in to comment.