Run black and fix tests

This commit is contained in:
Nuwan Goonasekera 2020-11-23 22:33:56 +05:30
commit c658cfea0d
No known key found for this signature in database
GPG key ID: 4C28B687668239D8
4 changed files with 32 additions and 20 deletions

View file

@ -1134,7 +1134,7 @@ class InstanceTypeBackend(object):
def describe_instance_types(self, instance_types=None):
matches = INSTANCE_TYPES.values()
if instance_types:
matches = [t for t in matches if t.get('apiname') in instance_types]
matches = [t for t in matches if t.get("apiname") in instance_types]
if len(instance_types) > len(matches):
unknown_ids = set(instance_types) - set(matches)
raise InvalidInstanceTypeError(unknown_ids)
@ -1153,14 +1153,15 @@ class InstanceTypeOfferingBackend(object):
for key, values in filters.items():
if key == "location":
if location_type in ("availability-zone", "availability-zone-id"):
return offering.get('location') in values
return offering.get("location") in values
elif location_type == "region":
return any(v for v in values
if offering.get('location').startswith(v))
return any(
v for v in values if offering.get("location").startswith(v)
)
else:
return False
elif key == "instance-type":
return offering.get('instance_type') in values
return offering.get("instance_type") in values
else:
return False
return True

View file

@ -152,7 +152,8 @@ class InstanceResponse(BaseResponse):
location_type_filters = self._get_multi_param("LocationType")
filter_dict = filters_from_querystring(self.querystring)
offerings = self.ec2_backend.describe_instance_type_offerings(
location_type_filters, filter_dict)
location_type_filters, filter_dict
)
template = self.response_template(EC2_DESCRIBE_INSTANCE_TYPE_OFFERINGS)
return template.render(instance_type_offerings=offerings)