Skip to content
Permalink
Browse files
Return empty set, instead of error if description of items is empty
  • Loading branch information
brogand93 committed Mar 5, 2014
1 parent 14d2f8e commit b14bd182ffec9cca6edde881d46fde9c3aaf552f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
@@ -9,7 +9,7 @@ def describe_item(args, keyname, not_found, prefix):
if helpers.contains_parameter_with_keyword(prefix):
response = _describe_specific_item(args, keyname, not_found, prefix)
else:
response = describe_items_request(args, not_found)
response = _describe_items_request(args, {})

return response

@@ -34,24 +34,26 @@ def _describe_specific_item(args, keyname, not_found, prefix):


def describe_item_request(args, keyname, not_found):
request = describe_items_request(args, not_found)
request = _describe_items_request(args, not_found)
request = request[keyname]

for item in request:
if 'id' in args and args['id'].lower() == item['id'].lower():
if 'id' in args and args['id'] == item['id']:
return item
elif 'name' in args and args['name'].lower() == item['name'].lower():
elif 'name' in args and args['name'] == item['name']:
return item

return not_found()


def describe_items_request(args, not_found):
def _describe_items_request(args, not_found):
args['listAll'] = 'true'
response = requester.make_request(args)
response = response[response.keys()[0]]

if 'count' in response:
return response
else:
elif callable(not_found):
return not_found()
else:
return not_found
@@ -1,6 +1,7 @@
{% extends "response.xml" %}
{% block response_content %}
<reservationSet>
{% if response %}
<item>
<reservationId>None</reservationId>
<instancesSet>
@@ -52,5 +53,6 @@
{% endfor %}
</instancesSet>
</item>
{% endif %}
</reservationSet>
{% endblock %}
@@ -75,7 +75,7 @@ def test_invalid_describe_image_by_id(self):
def test_empty_response_describe_images_by_id(self):
data = self.get_example_data()
data['Action'] = 'DescribeImages'
data['InstanceId.1'] = 'invalid-images-id'
data['ImageId.1'] = 'invalid-images-id'
data['Signature'] = generate_signature(data, 'POST', 'localhost')

get = mock.Mock()

0 comments on commit b14bd18

Please sign in to comment.