Skip to content

Commit f6dddce

Browse files
committed
sorted
1 parent e9e92fa commit f6dddce

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

packages/aws-library/src/aws_library/ec2/_client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ async def get_ec2_instance_capabilities(
6868
self,
6969
instance_type_names: set[InstanceTypeType],
7070
) -> list[EC2InstanceType]:
71-
"""returns the ec2 instance types from a list of instance type names
72-
NOTE: the order might differ!
71+
"""Returns the ec2 instance types from a list of instance type names (sorted by name)
72+
7373
Arguments:
74-
instance_type_names -- the types to filter with
74+
instance_type_names -- the types to filter with. If an empty set, it returns all.
7575
7676
Raises:
7777
Ec2InstanceTypeInvalidError: some invalid types were used as filter
@@ -95,7 +95,7 @@ async def get_ec2_instance_capabilities(
9595
),
9696
)
9797
)
98-
return list_instances
98+
return sorted(list_instances, key=lambda i: i.name)
9999

100100
@ec2_exception_handler(_logger)
101101
async def launch_instances(

packages/aws-library/tests/test_ec2_client.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,7 @@ async def test_get_ec2_instance_capabilities(
116116
)
117117
)
118118
assert instance_types
119-
assert len(instance_types) == len(ec2_allowed_instances)
120-
121-
# all the instance names are found and valid
122-
assert all(i.name in ec2_allowed_instances for i in instance_types)
123-
for instance_type_name in ec2_allowed_instances:
124-
assert any(i.name == instance_type_name for i in instance_types)
119+
assert [_.name for _ in instance_types] == sorted(ec2_allowed_instances)
125120

126121

127122
async def test_get_ec2_instance_capabilities_empty_list_returns_all_options(

0 commit comments

Comments
 (0)