adding owner id to amis v2 (#1331)

* Adding owner-id/OwnerId to the AMI classes to allow the value to be specified to test filtering images based on owner.

* Added default AMIs and filtering by owner-id

* Fixed some tests

* Fixed more random tests

* Updated MANIFEST

* .
This commit is contained in:
Terry Cain 2017-11-12 11:18:25 +00:00 committed by GitHub
commit bd8c1e4567
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 758 additions and 110 deletions

View file

@ -666,10 +666,6 @@ def test_ami_attribute_error_cases():
cm.exception.request_id.should_not.be.none
"""
Boto3
"""
@mock_ec2
def test_ami_filter_wildcard():
ec2 = boto3.resource('ec2', region_name='us-west-1')
@ -678,3 +674,20 @@ def test_ami_filter_wildcard():
filter_result = list(ec2.images.filter(Owners=['111122223333'], Filters=[{'Name':'name', 'Values':['test*']}]))
assert filter_result == [image]
@mock_ec2
def test_ami_filter_by_owner_id():
client = boto3.client('ec2', region_name='us-east-1')
ubuntu_id = '099720109477'
ubuntu_images = client.describe_images(Owners=[ubuntu_id])
all_images = client.describe_images()
ubuntu_ids = [ami['OwnerId'] for ami in ubuntu_images['Images']]
all_ids = [ami['OwnerId'] for ami in all_images['Images']]
# Assert all ubuntu_ids are the same and one equals ubuntu_id
assert all(ubuntu_ids) and ubuntu_ids[0] == ubuntu_id
# Check we actually have a subset of images
assert len(ubuntu_ids) < len(all_ids)