Fix:EC2-Create-Subnet availability Zone Id support (#3198)

* Fix:EC2-Create-Subnet availability Zone Id support

* Linting

* Fix:fixed build errors

* linting

Co-authored-by: Bert Blommers <bblommers@users.noreply.github.com>
Co-authored-by: Bert Blommers <info@bertblommers.nl>
Co-authored-by: usmankb <usman@krazybee.com>
This commit is contained in:
usmangani1 2020-08-27 21:01:39 +05:30 committed by GitHub
commit 1c939a5f06
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 55 additions and 16 deletions

View file

@ -75,6 +75,18 @@ def test_subnet_should_have_proper_availability_zone_set():
subnetA.availability_zone.should.equal("us-west-1b")
@mock_ec2
def test_availability_zone_in_create_subnet():
ec2 = boto3.resource("ec2", region_name="us-west-1")
vpc = ec2.create_vpc(CidrBlock="172.31.0.0/16")
subnet = ec2.create_subnet(
VpcId=vpc.id, CidrBlock="172.31.48.0/20", AvailabilityZoneId="use1-az6"
)
subnet.availability_zone_id.should.equal("use1-az6")
@mock_ec2
def test_default_subnet():
ec2 = boto3.resource("ec2", region_name="us-west-1")
@ -612,7 +624,15 @@ def test_run_instances_should_attach_to_default_subnet():
# Assert subnet is created appropriately
subnets = client.describe_subnets()["Subnets"]
default_subnet_id = subnets[0]["SubnetId"]
instances["Instances"][0]["NetworkInterfaces"][0]["SubnetId"].should.equal(
default_subnet_id
if len(subnets) > 1:
default_subnet_id1 = subnets[1]["SubnetId"]
assert (
instances["Instances"][0]["NetworkInterfaces"][0]["SubnetId"]
== default_subnet_id
or instances["Instances"][0]["NetworkInterfaces"][0]["SubnetId"]
== default_subnet_id1
)
assert (
subnets[0]["AvailableIpAddressCount"] == 4090
or subnets[1]["AvailableIpAddressCount"] == 4090
)
subnets[0]["AvailableIpAddressCount"].should.equal(4090)