mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #25194 from rallytime/fix-24272
Update moto version check in boto_vpc_test and update min version
This commit is contained in:
commit
9dd5cd8a8e
1 changed files with 30 additions and 43 deletions
|
@ -1,7 +1,21 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# import Third Party Libs
|
||||
from salttesting.mock import patch
|
||||
# Import Python Libs
|
||||
from distutils.version import LooseVersion # pylint: disable=no-name-in-module
|
||||
|
||||
# Import Salt Testing Libs
|
||||
from salttesting import skipIf, TestCase
|
||||
from salttesting.mock import NO_MOCK, NO_MOCK_REASON, patch
|
||||
from salttesting.helpers import ensure_in_syspath
|
||||
|
||||
ensure_in_syspath('../../')
|
||||
|
||||
# Import Salt Libs
|
||||
from salt.modules import boto_vpc
|
||||
from salt.exceptions import SaltInvocationError, CommandExecutionError
|
||||
from salt.modules.boto_vpc import _maybe_set_name_tag, _maybe_set_tags
|
||||
|
||||
# Import Third Party Libs
|
||||
# pylint: disable=import-error,no-name-in-module
|
||||
try:
|
||||
import boto
|
||||
|
@ -11,6 +25,7 @@ except ImportError:
|
|||
HAS_BOTO = False
|
||||
|
||||
try:
|
||||
import moto
|
||||
from moto import mock_ec2
|
||||
HAS_MOTO = True
|
||||
except ImportError:
|
||||
|
@ -29,25 +44,8 @@ except ImportError:
|
|||
|
||||
return stub_function
|
||||
|
||||
# Import Python libs
|
||||
from distutils.version import LooseVersion # pylint: disable=no-name-in-module
|
||||
# pylint: enable=import-error
|
||||
# pylint: enable=import-error,no-name-in-module
|
||||
|
||||
# Import Salt Libs
|
||||
from salt.modules import boto_vpc
|
||||
from salt.exceptions import SaltInvocationError, CommandExecutionError
|
||||
from salt.modules.boto_vpc import _maybe_set_name_tag, _maybe_set_tags
|
||||
|
||||
# Import Salt Testing Libs
|
||||
from salttesting import skipIf, TestCase
|
||||
from salttesting.mock import NO_MOCK, NO_MOCK_REASON
|
||||
from salttesting.helpers import ensure_in_syspath
|
||||
|
||||
ensure_in_syspath('../../')
|
||||
|
||||
# the boto_vpc module relies on the connect_to_region() method
|
||||
# which was added in boto 2.8.0
|
||||
# https://github.com/boto/boto/commit/33ac26b416fbb48a60602542b4ce15dcc7029f12
|
||||
required_boto_version = '2.8.0'
|
||||
required_moto_version = '0.3.7'
|
||||
|
||||
|
@ -83,13 +81,17 @@ def _has_required_moto():
|
|||
if not HAS_MOTO:
|
||||
return False
|
||||
else:
|
||||
import pkg_resources
|
||||
from pkg_resources import DistributionNotFound
|
||||
try:
|
||||
if LooseVersion(pkg_resources.get_distribution('moto').version) < LooseVersion(required_moto_version):
|
||||
if LooseVersion(moto.__version__) < LooseVersion(required_moto_version):
|
||||
return False
|
||||
except AttributeError:
|
||||
import pkg_resources
|
||||
from pkg_resources import DistributionNotFound
|
||||
try:
|
||||
if LooseVersion(pkg_resources.get_distribution('moto').version) < LooseVersion(required_moto_version):
|
||||
return False
|
||||
except DistributionNotFound:
|
||||
return False
|
||||
except DistributionNotFound:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
|
@ -179,6 +181,7 @@ class BotoVpcTestCaseBase(TestCase):
|
|||
@skipIf(_has_required_boto() is False, 'The boto module must be greater than'
|
||||
' or equal to version {0}'
|
||||
.format(required_boto_version))
|
||||
@skipIf(_has_required_moto() is False, 'The moto version must be >= to version {0}'.format(required_moto_version))
|
||||
class BotoVpcTestCase(BotoVpcTestCaseBase):
|
||||
'''
|
||||
TestCase for salt.modules.boto_vpc module
|
||||
|
@ -196,8 +199,6 @@ class BotoVpcTestCase(BotoVpcTestCaseBase):
|
|||
self.assertTrue(vpc_exists)
|
||||
|
||||
@mock_ec2
|
||||
@skipIf(_has_required_moto() is False, 'The moto module does not support filtering vpcs.'
|
||||
'Added support in spulec/moto#218. Next release should solve this issue.')
|
||||
def test_that_when_checking_if_a_vpc_exists_by_id_and_a_vpc_does_not_exist_the_vpc_exists_method_returns_false(
|
||||
self):
|
||||
'''
|
||||
|
@ -220,8 +221,6 @@ class BotoVpcTestCase(BotoVpcTestCaseBase):
|
|||
self.assertTrue(vpc_exists)
|
||||
|
||||
@mock_ec2
|
||||
@skipIf(_has_required_moto() is False, 'The moto module does not support filtering vpcs.'
|
||||
'Added support in spulec/moto#218. Next release should solve this issue.')
|
||||
def test_that_when_checking_if_a_vpc_exists_by_name_and_a_vpc_does_not_exist_the_vpc_exists_method_returns_false(
|
||||
self):
|
||||
'''
|
||||
|
@ -245,8 +244,6 @@ class BotoVpcTestCase(BotoVpcTestCaseBase):
|
|||
self.assertTrue(vpc_exists)
|
||||
|
||||
@mock_ec2
|
||||
@skipIf(_has_required_moto() is False, 'The moto module does not support filtering vpcs.'
|
||||
'Added support in spulec/moto#218. Next release should solve this issue.')
|
||||
def test_that_when_checking_if_a_vpc_exists_by_tags_and_a_vpc_does_not_exist_the_vpc_exists_method_returns_false(
|
||||
self):
|
||||
'''
|
||||
|
@ -270,8 +267,6 @@ class BotoVpcTestCase(BotoVpcTestCaseBase):
|
|||
self.assertTrue(vpc_exists)
|
||||
|
||||
@mock_ec2
|
||||
@skipIf(_has_required_moto() is False, 'The moto module does not support filtering vpcs.'
|
||||
'Added support in spulec/moto#218. Next release should solve this issue.')
|
||||
def test_that_when_checking_if_a_vpc_exists_by_cidr_and_a_vpc_does_not_exist_the_vpc_exists_method_returns_false(
|
||||
self):
|
||||
'''
|
||||
|
@ -491,6 +486,7 @@ class BotoVpcTestCase(BotoVpcTestCaseBase):
|
|||
@skipIf(_has_required_boto() is False, 'The boto module must be greater than'
|
||||
' or equal to version {0}'
|
||||
.format(required_boto_version))
|
||||
@skipIf(_has_required_moto() is False, 'The moto version must be >= to version {0}'.format(required_moto_version))
|
||||
class BotoVpcSubnetsTestCase(BotoVpcTestCaseBase):
|
||||
@mock_ec2
|
||||
def test_get_subnet_association_single_subnet(self):
|
||||
|
@ -621,8 +617,6 @@ class BotoVpcSubnetsTestCase(BotoVpcTestCaseBase):
|
|||
self.assertFalse(subnet_exists_result)
|
||||
|
||||
@mock_ec2
|
||||
@skipIf(_has_required_moto() is False, 'The moto module does not support filtering by tags. '
|
||||
'Added support in spulec/moto#218. Next release should solve this issue.')
|
||||
def test_that_when_checking_if_a_subnet_exists_by_name_the_subnet_exists_method_returns_true(self):
|
||||
'''
|
||||
Tests checking subnet existence by name
|
||||
|
@ -635,8 +629,6 @@ class BotoVpcSubnetsTestCase(BotoVpcTestCaseBase):
|
|||
self.assertTrue(subnet_exists_result)
|
||||
|
||||
@mock_ec2
|
||||
@skipIf(_has_required_moto() is False, 'The moto module does not support filtering by tags. '
|
||||
'Added support in spulec/moto#218. Next release should solve this issue.')
|
||||
def test_that_when_checking_if_a_subnet_exists_by_name_the_subnet_does_not_exist_the_subnet_method_returns_false(self):
|
||||
'''
|
||||
Tests checking subnet existence by name when it doesn't exist
|
||||
|
@ -649,8 +641,6 @@ class BotoVpcSubnetsTestCase(BotoVpcTestCaseBase):
|
|||
self.assertFalse(subnet_exists_result)
|
||||
|
||||
@mock_ec2
|
||||
@skipIf(_has_required_moto() is False, 'The moto module does not support filtering by tags. '
|
||||
'Added support in spulec/moto#218. Next release should solve this issue.')
|
||||
def test_that_when_checking_if_a_subnet_exists_by_tags_the_subnet_exists_method_returns_true(self):
|
||||
'''
|
||||
Tests checking subnet existence by tag
|
||||
|
@ -663,8 +653,6 @@ class BotoVpcSubnetsTestCase(BotoVpcTestCaseBase):
|
|||
self.assertTrue(subnet_exists_result)
|
||||
|
||||
@mock_ec2
|
||||
@skipIf(_has_required_moto() is False, 'The moto module does not support filtering by tags. '
|
||||
'Added support in spulec/moto#218. Next release should solve this issue.')
|
||||
def test_that_when_checking_if_a_subnet_exists_by_tags_the_subnet_does_not_exist_the_subnet_method_returns_false(self):
|
||||
'''
|
||||
Tests checking subnet existence by tag when subnet doesn't exist
|
||||
|
@ -691,8 +679,7 @@ class BotoVpcSubnetsTestCase(BotoVpcTestCaseBase):
|
|||
@skipIf(_has_required_boto() is False, 'The boto module must be greater than'
|
||||
' or equal to version {0}'
|
||||
.format(required_boto_version))
|
||||
@skipIf(_has_required_moto() is False, 'The moto module has a bug in creating DHCP options which is fixed '
|
||||
'in spulec/moto#214. Next release should solve this issue.')
|
||||
@skipIf(_has_required_moto() is False, 'The moto version must be >= to version {0}'.format(required_moto_version))
|
||||
class BotoVpcDHCPOptionsTestCase(BotoVpcTestCaseBase):
|
||||
@mock_ec2
|
||||
def test_that_when_creating_dhcp_options_succeeds_the_create_dhcp_options_method_returns_true(self):
|
||||
|
|
Loading…
Add table
Reference in a new issue