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

Fixed boto_vpc_test failure #34141

Merged
merged 3 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
38 changes: 25 additions & 13 deletions tests/unit/modules/boto_vpc_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

# Import Python Libs
from distutils.version import LooseVersion # pylint: disable=no-name-in-module
import pkg_resources
from pkg_resources import DistributionNotFound

# Import Salt Testing Libs
from salttesting import skipIf, TestCase
Expand Down Expand Up @@ -73,6 +75,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 @@ -81,17 +96,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 @@ -436,14 +442,20 @@ 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(cidr_block=unicode(cidr_block),
is_default=False,
is_default=is_default,
state=u'available',
tags={'Name': 'test', 'test': 'testvalue'},
tags={u'Name': u'test', u'test': u'testvalue'},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you positive that these should be designated as Unicode strings as a return from this function?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cachedout The test is failing for this on 2015.5 and 2015.8+ already has them designated as unicode.

dhcp_options_id=u'dopt-7a8b9c2d',
instance_tenancy=u'default')

Expand Down