EC2 - Filtering on plain property didn't work with asterix (#4461)

This commit is contained in:
Bert Blommers 2021-10-23 11:29:16 +00:00 committed by GitHub
parent 665c8aa3bc
commit 728039bce1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 1 deletions

View File

@ -270,7 +270,7 @@ class TaggedEC2Resource(BaseModel):
value = getattr(self, filter_name.lower().replace("-", "_"), None)
if value is not None:
return [value]
return value
raise FilterNotImplementedError(filter_name, method_name)

View File

@ -1339,6 +1339,31 @@ def test_ami_attribute_user_and_group_permissions_boto3():
image.public.should.equal(False)
@mock_ec2
def test_filter_description():
# https://github.com/spulec/moto/issues/4460
client = boto3.client("ec2", region_name="us-west-2")
# Search for partial description
resp = client.describe_images(
Owners=["amazon"],
Filters=[{"Name": "description", "Values": ["Amazon Linux AMI*"]}],
)["Images"]
resp.should.have.length_of(4)
# Search for full description
resp = client.describe_images(
Owners=["amazon"],
Filters=[
{
"Name": "description",
"Values": ["Amazon Linux AMI 2018.03.0.20210721.0 x86_64 VPC HVM ebs"],
}
],
)["Images"]
resp.should.have.length_of(1)
# Has boto3 equivalent
@mock_ec2_deprecated
def test_ami_attribute_error_cases():