EC2 - Filtering on plain property didn't work with asterix (#4461)
This commit is contained in:
parent
665c8aa3bc
commit
728039bce1
@ -270,7 +270,7 @@ class TaggedEC2Resource(BaseModel):
|
|||||||
|
|
||||||
value = getattr(self, filter_name.lower().replace("-", "_"), None)
|
value = getattr(self, filter_name.lower().replace("-", "_"), None)
|
||||||
if value is not None:
|
if value is not None:
|
||||||
return [value]
|
return value
|
||||||
|
|
||||||
raise FilterNotImplementedError(filter_name, method_name)
|
raise FilterNotImplementedError(filter_name, method_name)
|
||||||
|
|
||||||
|
@ -1339,6 +1339,31 @@ def test_ami_attribute_user_and_group_permissions_boto3():
|
|||||||
image.public.should.equal(False)
|
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
|
# Has boto3 equivalent
|
||||||
@mock_ec2_deprecated
|
@mock_ec2_deprecated
|
||||||
def test_ami_attribute_error_cases():
|
def test_ami_attribute_error_cases():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user