From 65d51a58441140949c107f72c883cffb66964489 Mon Sep 17 00:00:00 2001 From: Hugo Lopes Tavares Date: Wed, 8 Apr 2015 16:47:43 -0400 Subject: [PATCH] Make availability zone dynamic in Subnet Response templates --- moto/ec2/responses/subnets.py | 4 ++-- tests/test_ec2/test_subnets.py | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/moto/ec2/responses/subnets.py b/moto/ec2/responses/subnets.py index f0cd6db33..a0798a615 100644 --- a/moto/ec2/responses/subnets.py +++ b/moto/ec2/responses/subnets.py @@ -41,7 +41,7 @@ CREATE_SUBNET_RESPONSE = """ {{ subnet.vpc_id }} {{ subnet.cidr_block }} 251 - us-east-1a + {{ subnet.availability_zone }} {% for tag in subnet.get_tags() %} @@ -72,7 +72,7 @@ DESCRIBE_SUBNETS_RESPONSE = """ {{ subnet.vpc_id }} {{ subnet.cidr_block }} 251 - us-east-1a + {{ subnet.availability_zone }} {% for tag in subnet.get_tags() %} diff --git a/tests/test_ec2/test_subnets.py b/tests/test_ec2/test_subnets.py index e148eac61..6205a50f2 100644 --- a/tests/test_ec2/test_subnets.py +++ b/tests/test_ec2/test_subnets.py @@ -61,6 +61,14 @@ def test_subnet_tagging(): subnet.tags["a key"].should.equal("some value") +@mock_ec2 +def test_subnet_should_have_proper_availability_zone_set(): + conn = boto.vpc.connect_to_region('us-west-1') + vpcA = conn.create_vpc("10.0.0.0/16") + subnetA = conn.create_subnet(vpcA.id, "10.0.0.0/24", availability_zone='us-west-1b') + subnetA.availability_zone.should.equal('us-west-1b') + + @mock_ec2 def test_get_subnets_filtering(): conn = boto.vpc.connect_to_region('us-west-1')