Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2015.8] Merge forward from 2015.5 to 2015.8 #34184

Merged
merged 5 commits into from
Jun 21, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 24 additions & 12 deletions tests/unit/modules/boto_vpc_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# Import Python libs
from __future__ import absolute_import
from distutils.version import LooseVersion # pylint: disable=import-error,no-name-in-module
import pkg_resources
from pkg_resources import DistributionNotFound

# Import Salt Testing libs
from salttesting.unit import skipIf, TestCase
Expand Down Expand Up @@ -90,6 +92,19 @@ def _has_required_boto():
return True


def _get_moto_version():
'''
Returns the moto version
'''
try:
return LooseVersion(moto.__version__)
except AttributeError:
try:
return LooseVersion(pkg_resources.get_distribution('moto').version)
except DistributionNotFound:
return False


def _has_required_moto():
'''
Returns True/False boolean depending on if Moto is installed and correct
Expand All @@ -98,17 +113,8 @@ def _has_required_moto():
if not HAS_MOTO:
return False
else:
try:
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
if _get_moto_version() < LooseVersion(required_moto_version):
return False
return True


Expand Down Expand Up @@ -488,13 +494,19 @@ def test_that_when_describing_vpc_by_id_it_returns_the_dict_of_properties_return
'''
Tests describing parameters via vpc id if vpc exist
'''
# With moto 0.4.25 is_default is set to True. 0.4.24 and older, is_default is False
if _get_moto_version() >= LooseVersion('0.4.25'):
is_default = True
else:
is_default = False

vpc = self._create_vpc(name='test', tags={'test': 'testvalue'})

describe_vpc = boto_vpc.describe(vpc_id=vpc.id, **conn_parameters)

vpc_properties = dict(id=vpc.id,
cidr_block=six.text_type(cidr_block),
is_default=False,
is_default=is_default,
state=u'available',
tags={u'Name': u'test', u'test': u'testvalue'},
dhcp_options_id=u'dopt-7a8b9c2d',
Expand Down