From e4f8340201bc3847ea480a235d2cd69d119f4eb1 Mon Sep 17 00:00:00 2001 From: Omer Katz Date: Sun, 28 Sep 2014 18:19:33 +0300 Subject: [PATCH] Added unit tests that verify that subnet creation reports success/failure correctly. --- tests/unit/modules/boto_vpc_test.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/unit/modules/boto_vpc_test.py b/tests/unit/modules/boto_vpc_test.py index 0274497bc8..1e1d398707 100644 --- a/tests/unit/modules/boto_vpc_test.py +++ b/tests/unit/modules/boto_vpc_test.py @@ -149,6 +149,25 @@ class BotoVpcTestCase(TestCase): self.assertFalse(vpc_creation_result) + @mock_ec2 + def test_that_when_creating_a_subnet_succeeds_the_create_subnet_method_returns_true(self): + conn = boto.vpc.connect_to_region(region) + vpc = conn.create_vpc(cidr_block) + + subnet_creation_result = boto_vpc.create_subnet(vpc.id, '10.0.0.0/24', **conn_parameters) + + self.assertTrue(subnet_creation_result) + + @mock_ec2 + def test_that_when_creating_a_subnet_fails_the_create_subnet_method_returns_false(self): + conn = boto.vpc.connect_to_region(region) + vpc = conn.create_vpc(cidr_block) + + with patch('moto.ec2.models.SubnetBackend.create_subnet', side_effect=BotoServerError(400, 'Mocked error')): + subnet_creation_result = boto_vpc.create_subnet(vpc.id, '10.0.0.0/24', **conn_parameters) + + self.assertFalse(subnet_creation_result) + if __name__ == '__main__': from integration import run_tests