diff options
author | Joshua Harlow <harlowja@gmail.com> | 2014-02-13 13:54:43 -0500 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2014-02-13 13:54:43 -0500 |
commit | 9be5a7aa77b9679c50583666dcfd3ee811a65522 (patch) | |
tree | f46e7a9ebbe07bdc7a8957944bc7f0ccdb289f10 /tests/unittests/helpers.py | |
parent | 322e404dcbb891bbdecd1da50e6b4789781a71d5 (diff) | |
parent | b8f1c6f27345d1aa0ef550a72bd34c2d7bd4ed41 (diff) | |
download | vyos-cloud-init-9be5a7aa77b9679c50583666dcfd3ee811a65522.tar.gz vyos-cloud-init-9be5a7aa77b9679c50583666dcfd3ee811a65522.zip |
Add a openstack specific datasource
Openstack has a unique derivative datasource that is gaining usage.
Previously the config drive datasource provided part of this functionality
as well as the ec2 datasource, but since new functionality is being added
to openstack's special datasource it seems beneficial to combine the used
parts into a new datasource just made for handling openstack deployments
that use the openstack metadata service (possibly in combination with the
ec2 metadata service).
This patch factors out the common logic shared between the config drive
and the openstack metadata datasource and places that in a shared helper
file and then creates a new openstack datasource that readers from the
openstack metadata service and refactors the config drive datasource to
use this common logic.
Diffstat (limited to 'tests/unittests/helpers.py')
-rw-r--r-- | tests/unittests/helpers.py | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/tests/unittests/helpers.py b/tests/unittests/helpers.py index 5b4f4208..5bed13cc 100644 --- a/tests/unittests/helpers.py +++ b/tests/unittests/helpers.py @@ -12,10 +12,27 @@ from cloudinit import util import shutil -# Handle how 2.6 doesn't have the assertIn or assertNotIn +# Used for detecting different python versions +PY2 = False +PY26 = False +PY27 = False +PY3 = False + _PY_VER = sys.version_info _PY_MAJOR, _PY_MINOR = _PY_VER[0:2] if (_PY_MAJOR, _PY_MINOR) <= (2, 6): + if (_PY_MAJOR, _PY_MINOR) == (2, 6): + PY26 = True + if (_PY_MAJOR, _PY_MINOR) >= (2, 0): + PY2 = True +else: + if (_PY_MAJOR, _PY_MINOR) == (2, 7): + PY27 = True + PY2 = True + if (_PY_MAJOR, _PY_MINOR) >= (3, 0): + PY3 = True + +if PY26: # For now add these on, taken from python 2.7 + slightly adjusted class TestCase(unittest.TestCase): def assertIn(self, member, container, msg=None): @@ -29,6 +46,12 @@ if (_PY_MAJOR, _PY_MINOR) <= (2, 6): standardMsg = standardMsg % (member, container) self.fail(self._formatMessage(msg, standardMsg)) + def assertIsNone(self, value, msg=None): + if value is not None: + standardMsg = '%r is not None' + standardMsg = standardMsg % (value) + self.fail(self._formatMessage(msg, standardMsg)) + else: class TestCase(unittest.TestCase): pass |