mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #28299 from rallytime/tests-for-28168
Add test for availability_zone check to boto_vpc_tests
This commit is contained in:
commit
93a930615e
1 changed files with 13 additions and 4 deletions
|
@ -1,11 +1,10 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# TODO: Update skipped tests to expect dicttionary results from the execution
|
||||
# TODO: Update skipped tests to expect dictionary results from the execution
|
||||
# module functions.
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
|
||||
from distutils.version import LooseVersion # pylint: disable=import-error,no-name-in-module
|
||||
|
||||
# Import Salt Testing libs
|
||||
|
@ -132,14 +131,14 @@ class BotoVpcTestCaseMixin(object):
|
|||
_maybe_set_tags(tags, vpc)
|
||||
return vpc
|
||||
|
||||
def _create_subnet(self, vpc_id, cidr_block='10.0.0.0/25', name=None, tags=None):
|
||||
def _create_subnet(self, vpc_id, cidr_block='10.0.0.0/25', name=None, tags=None, availability_zone=None):
|
||||
'''
|
||||
Helper function to create a test subnet
|
||||
'''
|
||||
if not self.conn:
|
||||
self.conn = boto.vpc.connect_to_region(region)
|
||||
|
||||
subnet = self.conn.create_subnet(vpc_id, cidr_block)
|
||||
subnet = self.conn.create_subnet(vpc_id, cidr_block, availability_zone=availability_zone)
|
||||
_maybe_set_name_tag(name, subnet)
|
||||
_maybe_set_tags(tags, subnet)
|
||||
return subnet
|
||||
|
@ -795,6 +794,16 @@ class BotoVpcSubnetsTestCase(BotoVpcTestCaseBase, BotoVpcTestCaseMixin):
|
|||
self.assertEqual(set(describe_subnet_results['subnets'][0].keys()),
|
||||
set(['id', 'cidr_block', 'availability_zone', 'tags']))
|
||||
|
||||
@mock_ec2
|
||||
def test_create_subnet_passes_availability_zone(self):
|
||||
'''
|
||||
Tests that the availability_zone kwarg is passed on to _create_resource
|
||||
'''
|
||||
vpc = self._create_vpc()
|
||||
self._create_subnet(vpc.id, name='subnet1', availability_zone='us-east-1a')
|
||||
describe_subnet_results = boto_vpc.describe_subnets(subnet_names=['subnet1'])
|
||||
self.assertEqual(describe_subnet_results['subnets'][0]['availability_zone'], 'us-east-1a')
|
||||
|
||||
|
||||
@skipIf(NO_MOCK, NO_MOCK_REASON)
|
||||
@skipIf(HAS_BOTO is False, 'The boto module must be installed.')
|
||||
|
|
Loading…
Add table
Reference in a new issue