summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2014-09-02 12:18:21 -0400
committerScott Moser <smoser@ubuntu.com>2014-09-02 12:18:21 -0400
commitcc77628e1ee3cd03d1ec2e17f1d744c8f4b0938b (patch)
treee9bdcbc699eda6db5e57d35b25d222bead96da12 /tests
parentfbfd3789ede42ad50e0b79f202ab18b65537af52 (diff)
parente39abc783f7edd6435dbc7ea1fc3d02e6b3955d3 (diff)
downloadvyos-cloud-init-cc77628e1ee3cd03d1ec2e17f1d744c8f4b0938b.tar.gz
vyos-cloud-init-cc77628e1ee3cd03d1ec2e17f1d744c8f4b0938b.zip
merge from trunk
Diffstat (limited to 'tests')
-rw-r--r--tests/unittests/test__init__.py3
-rw-r--r--tests/unittests/test_datasource/test_azure.py2
-rw-r--r--tests/unittests/test_datasource/test_nocloud.py4
-rw-r--r--tests/unittests/test_datasource/test_openstack.py23
-rw-r--r--tests/unittests/test_distros/test_generic.py6
-rw-r--r--tests/unittests/test_handler/test_handler_growpart.py10
-rw-r--r--tests/unittests/test_handler/test_handler_power_state.py2
-rw-r--r--tests/unittests/test_handler/test_handler_yum_add_repo.py2
-rw-r--r--tests/unittests/test_merging.py2
-rw-r--r--tests/unittests/test_util.py6
10 files changed, 35 insertions, 25 deletions
diff --git a/tests/unittests/test__init__.py b/tests/unittests/test__init__.py
index 03065c8b..17965488 100644
--- a/tests/unittests/test__init__.py
+++ b/tests/unittests/test__init__.py
@@ -18,8 +18,7 @@ class FakeModule(handlers.Handler):
def list_types(self):
return self.types
- def handle_part(self, _data, ctype, filename, # pylint: disable=W0221
- payload, frequency):
+ def handle_part(self, data, ctype, filename, payload, frequency):
pass
diff --git a/tests/unittests/test_datasource/test_azure.py b/tests/unittests/test_datasource/test_azure.py
index 88c82d5e..e992a006 100644
--- a/tests/unittests/test_datasource/test_azure.py
+++ b/tests/unittests/test_datasource/test_azure.py
@@ -235,7 +235,7 @@ class TestAzureDataSource(MockerTestCase):
self.assertEqual(dsrc.userdata_raw, mydata)
def test_no_datasource_expected(self):
- #no source should be found if no seed_dir and no devs
+ # no source should be found if no seed_dir and no devs
data = {}
dsrc = self._get_ds({})
ret = dsrc.get_data()
diff --git a/tests/unittests/test_datasource/test_nocloud.py b/tests/unittests/test_datasource/test_nocloud.py
index 14274562..8bcc026c 100644
--- a/tests/unittests/test_datasource/test_nocloud.py
+++ b/tests/unittests/test_datasource/test_nocloud.py
@@ -50,7 +50,7 @@ class TestNoCloudDataSource(MockerTestCase):
self.assertTrue(ret)
def test_fs_label(self):
- #find_devs_with should not be called ff fs_label is None
+ # find_devs_with should not be called ff fs_label is None
ds = DataSourceNoCloud.DataSourceNoCloud
class PsuedoException(Exception):
@@ -74,7 +74,7 @@ class TestNoCloudDataSource(MockerTestCase):
self.assertFalse(ret)
def test_no_datasource_expected(self):
- #no source should be found if no cmdline, config, and fs_label=None
+ # no source should be found if no cmdline, config, and fs_label=None
sys_cfg = {'datasource': {'NoCloud': {'fs_label': None}}}
ds = DataSourceNoCloud.DataSourceNoCloud
diff --git a/tests/unittests/test_datasource/test_openstack.py b/tests/unittests/test_datasource/test_openstack.py
index f43cbec8..530fba20 100644
--- a/tests/unittests/test_datasource/test_openstack.py
+++ b/tests/unittests/test_datasource/test_openstack.py
@@ -67,8 +67,8 @@ OSTACK_META = {
CONTENT_0 = 'This is contents of /etc/foo.cfg\n'
CONTENT_1 = '# this is /etc/bar/bar.cfg\n'
OS_FILES = {
- 'openstack/2012-08-10/meta_data.json': json.dumps(OSTACK_META),
- 'openstack/2012-08-10/user_data': USER_DATA,
+ 'openstack/latest/meta_data.json': json.dumps(OSTACK_META),
+ 'openstack/latest/user_data': USER_DATA,
'openstack/content/0000': CONTENT_0,
'openstack/content/0001': CONTENT_1,
'openstack/latest/meta_data.json': json.dumps(OSTACK_META),
@@ -78,6 +78,9 @@ OS_FILES = {
EC2_FILES = {
'latest/user-data': USER_DATA,
}
+EC2_VERSIONS = [
+ 'latest',
+]
def _register_uris(version, ec2_files, ec2_meta, os_files):
@@ -85,6 +88,9 @@ def _register_uris(version, ec2_files, ec2_meta, os_files):
same data returned by the openstack metadata service (and ec2 service)."""
def match_ec2_url(uri, headers):
+ path = uri.path.strip("/")
+ if len(path) == 0:
+ return (200, headers, "\n".join(EC2_VERSIONS))
path = uri.path.lstrip("/")
if path in ec2_files:
return (200, headers, ec2_files.get(path))
@@ -110,11 +116,20 @@ def _register_uris(version, ec2_files, ec2_meta, os_files):
return (200, headers, str(value))
return (404, headers, '')
- def get_request_callback(method, uri, headers):
- uri = urlparse(uri)
+ def match_os_uri(uri, headers):
+ path = uri.path.strip("/")
+ if path == 'openstack':
+ return (200, headers, "\n".join([openstack.OS_LATEST]))
path = uri.path.lstrip("/")
if path in os_files:
return (200, headers, os_files.get(path))
+ return (404, headers, '')
+
+ def get_request_callback(method, uri, headers):
+ uri = urlparse(uri)
+ path = uri.path.lstrip("/").split("/")
+ if path[0] == 'openstack':
+ return match_os_uri(uri, headers)
return match_ec2_url(uri, headers)
hp.register_uri(hp.GET, re.compile(r'http://169.254.169.254/.*'),
diff --git a/tests/unittests/test_distros/test_generic.py b/tests/unittests/test_distros/test_generic.py
index c24c790e..db6aa0e8 100644
--- a/tests/unittests/test_distros/test_generic.py
+++ b/tests/unittests/test_distros/test_generic.py
@@ -26,8 +26,8 @@ package_mirrors = [
unknown_arch_info
]
-gpmi = distros._get_package_mirror_info # pylint: disable=W0212
-gapmi = distros._get_arch_package_mirror_info # pylint: disable=W0212
+gpmi = distros._get_package_mirror_info
+gapmi = distros._get_arch_package_mirror_info
class TestGenericDistro(helpers.FilesystemMockingTestCase):
@@ -193,7 +193,7 @@ class TestGenericDistro(helpers.FilesystemMockingTestCase):
'security': 'http://security-mirror2-intel'})
-#def _get_package_mirror_info(mirror_info, availability_zone=None,
+# def _get_package_mirror_info(mirror_info, availability_zone=None,
# mirror_filter=util.search_for_mirror):
diff --git a/tests/unittests/test_handler/test_handler_growpart.py b/tests/unittests/test_handler/test_handler_growpart.py
index f6dc4521..5d0636d1 100644
--- a/tests/unittests/test_handler/test_handler_growpart.py
+++ b/tests/unittests/test_handler/test_handler_growpart.py
@@ -53,7 +53,7 @@ class TestDisabled(MockerTestCase):
self.handle = cc_growpart.handle
def test_mode_off(self):
- #Test that nothing is done if mode is off.
+ # Test that nothing is done if mode is off.
# this really only verifies that resizer_factory isn't called
config = {'growpart': {'mode': 'off'}}
@@ -109,7 +109,7 @@ class TestConfig(MockerTestCase):
self.assertTrue(isinstance(ret, cc_growpart.ResizeGrowPart))
def test_handle_with_no_growpart_entry(self):
- #if no 'growpart' entry in config, then mode=auto should be used
+ # if no 'growpart' entry in config, then mode=auto should be used
myresizer = object()
@@ -141,7 +141,7 @@ class TestResize(MockerTestCase):
self.mocker.order()
def test_simple_devices(self):
- #test simple device list
+ # test simple device list
# this patches out devent2dev, os.stat, and device_part_info
# so in the end, doesn't test a lot
devs = ["/dev/XXda1", "/dev/YYda2"]
@@ -187,7 +187,7 @@ class TestResize(MockerTestCase):
find("/dev/YYda2", resized)[1])
self.assertEqual(cc_growpart.RESIZE.SKIPPED,
find(enoent[0], resized)[1])
- #self.assertEqual(resize_calls,
+ # self.assertEqual(resize_calls,
# [("/dev/XXda", "1", "/dev/XXda1"),
# ("/dev/YYda", "2", "/dev/YYda2")])
finally:
@@ -203,8 +203,6 @@ def simple_device_part_info(devpath):
class Bunch(object):
- st_mode = None # fix pylint complaint
-
def __init__(self, **kwds):
self.__dict__.update(kwds)
diff --git a/tests/unittests/test_handler/test_handler_power_state.py b/tests/unittests/test_handler/test_handler_power_state.py
index 4b7b2112..2f86b8f8 100644
--- a/tests/unittests/test_handler/test_handler_power_state.py
+++ b/tests/unittests/test_handler/test_handler_power_state.py
@@ -67,7 +67,7 @@ def check_lps_ret(psc_return, mode=None):
cmd = psc_return[0]
timeout = psc_return[1]
- if not 'shutdown' in psc_return[0][0]:
+ if 'shutdown' not in psc_return[0][0]:
errs.append("string 'shutdown' not in cmd")
if mode is not None:
diff --git a/tests/unittests/test_handler/test_handler_yum_add_repo.py b/tests/unittests/test_handler/test_handler_yum_add_repo.py
index 156441c7..21b89c34 100644
--- a/tests/unittests/test_handler/test_handler_yum_add_repo.py
+++ b/tests/unittests/test_handler/test_handler_yum_add_repo.py
@@ -24,7 +24,7 @@ class TestConfig(helpers.FilesystemMockingTestCase):
'epel-testing': {
'name': 'Extra Packages for Enterprise Linux 5 - Testing',
# Missing this should cause the repo not to be written
- #'baseurl': 'http://blah.org/pub/epel/testing/5/$basearch',
+ # 'baseurl': 'http://blah.org/pub/epel/testing/5/$basearch',
'enabled': False,
'gpgcheck': True,
'gpgkey': 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL',
diff --git a/tests/unittests/test_merging.py b/tests/unittests/test_merging.py
index 17704f8e..07b610f7 100644
--- a/tests/unittests/test_merging.py
+++ b/tests/unittests/test_merging.py
@@ -11,7 +11,7 @@ import glob
import os
import random
import re
-import string # pylint: disable=W0402
+import string
SOURCE_PAT = "source*.*yaml"
EXPECTED_PAT = "expected%s.yaml"
diff --git a/tests/unittests/test_util.py b/tests/unittests/test_util.py
index 0cb41520..35e92445 100644
--- a/tests/unittests/test_util.py
+++ b/tests/unittests/test_util.py
@@ -1,5 +1,3 @@
-# pylint: disable=C0301
-# the mountinfo data lines are too long
import os
import stat
import yaml
@@ -18,7 +16,7 @@ class FakeSelinux(object):
self.match_what = match_what
self.restored = []
- def matchpathcon(self, path, mode): # pylint: disable=W0613
+ def matchpathcon(self, path, mode):
if path == self.match_what:
return
else:
@@ -27,7 +25,7 @@ class FakeSelinux(object):
def is_selinux_enabled(self):
return True
- def restorecon(self, path, recursive): # pylint: disable=W0613
+ def restorecon(self, path, recursive):
self.restored.append(path)