diff options
Diffstat (limited to 'tests/unittests')
-rw-r--r-- | tests/unittests/test__init__.py | 21 | ||||
-rw-r--r-- | tests/unittests/test_builtin_handlers.py | 1 | ||||
-rw-r--r-- | tests/unittests/test_datasource/test_maas.py | 2 | ||||
-rw-r--r-- | tests/unittests/test_handler/test_handler_ca_certs.py | 14 | ||||
-rw-r--r-- | tests/unittests/test_userdata.py | 4 | ||||
-rw-r--r-- | tests/unittests/test_util.py | 4 |
6 files changed, 24 insertions, 22 deletions
diff --git a/tests/unittests/test__init__.py b/tests/unittests/test__init__.py index af18955d..464c8c2f 100644 --- a/tests/unittests/test__init__.py +++ b/tests/unittests/test__init__.py @@ -50,12 +50,14 @@ class TestWalkerHandleHandler(MockerTestCase): self.payload = "dummy payload" # Mock the write_file function - write_file_mock = self.mocker.replace(util.write_file, passthrough=False) + write_file_mock = self.mocker.replace(util.write_file, + passthrough=False) write_file_mock(expected_file_fullname, self.payload, 0600) def test_no_errors(self): """Payload gets written to file and added to C{pdata}.""" - import_mock = self.mocker.replace(importer.import_module, passthrough=False) + import_mock = self.mocker.replace(importer.import_module, + passthrough=False) import_mock(self.expected_module_name) self.mocker.result(self.module_fake) self.mocker.replay() @@ -67,7 +69,8 @@ class TestWalkerHandleHandler(MockerTestCase): def test_import_error(self): """Module import errors are logged. No handler added to C{pdata}""" - import_mock = self.mocker.replace(importer.import_module, passthrough=False) + import_mock = self.mocker.replace(importer.import_module, + passthrough=False) import_mock(self.expected_module_name) self.mocker.throw(ImportError()) self.mocker.replay() @@ -79,7 +82,8 @@ class TestWalkerHandleHandler(MockerTestCase): def test_attribute_error(self): """Attribute errors are logged. No handler added to C{pdata}""" - import_mock = self.mocker.replace(importer.import_module, passthrough=False) + import_mock = self.mocker.replace(importer.import_module, + passthrough=False) import_mock(self.expected_module_name) self.mocker.result(self.module_fake) self.mocker.throw(AttributeError()) @@ -185,13 +189,15 @@ class TestCmdlineUrl(MockerTestCase): payload = "0" cmdline = "ro %s=%s bar=1" % (key, url) - mock_readurl = self.mocker.replace(url_helper.readurl, passthrough=False) + mock_readurl = self.mocker.replace(url_helper.readurl, + passthrough=False) mock_readurl(url) self.mocker.result(url_helper.UrlResponse(200, payload)) self.mocker.replay() self.assertEqual((key, url, None), - util.get_cmdline_url(names=[key], starts="xxxxxx", cmdline=cmdline)) + util.get_cmdline_url(names=[key], starts="xxxxxx", + cmdline=cmdline)) def test_valid_content(self): url = "http://example.com/foo" @@ -199,7 +205,8 @@ class TestCmdlineUrl(MockerTestCase): payload = "xcloud-config\nmydata: foo\nbar: wark\n" cmdline = "ro %s=%s bar=1" % (key, url) - mock_readurl = self.mocker.replace(url_helper.readurl, passthrough=False) + mock_readurl = self.mocker.replace(url_helper.readurl, + passthrough=False) mock_readurl(url) self.mocker.result(url_helper.UrlResponse(200, payload)) self.mocker.replay() diff --git a/tests/unittests/test_builtin_handlers.py b/tests/unittests/test_builtin_handlers.py index 84d85d4d..5bba8bc9 100644 --- a/tests/unittests/test_builtin_handlers.py +++ b/tests/unittests/test_builtin_handlers.py @@ -6,7 +6,6 @@ from mocker import MockerTestCase from cloudinit import handlers from cloudinit import helpers -from cloudinit import util from cloudinit.handlers import upstart_job diff --git a/tests/unittests/test_datasource/test_maas.py b/tests/unittests/test_datasource/test_maas.py index 261c410a..8a155f39 100644 --- a/tests/unittests/test_datasource/test_maas.py +++ b/tests/unittests/test_datasource/test_maas.py @@ -1,8 +1,6 @@ import os -from StringIO import StringIO from copy import copy -from cloudinit import util from cloudinit import url_helper from cloudinit.sources import DataSourceMAAS diff --git a/tests/unittests/test_handler/test_handler_ca_certs.py b/tests/unittests/test_handler/test_handler_ca_certs.py index 1f96e992..948de4c4 100644 --- a/tests/unittests/test_handler/test_handler_ca_certs.py +++ b/tests/unittests/test_handler/test_handler_ca_certs.py @@ -26,7 +26,8 @@ class TestNoConfig(MockerTestCase): self.mocker.replace(cc_ca_certs.update_ca_certs, passthrough=False) self.mocker.replay() - cc_ca_certs.handle(self.name, config, self.cloud_init, self.log, self.args) + cc_ca_certs.handle(self.name, config, self.cloud_init, self.log, + self.args) class TestConfig(MockerTestCase): @@ -39,11 +40,12 @@ class TestConfig(MockerTestCase): self.args = [] # Mock out the functions that actually modify the system - self.mock_add = self.mocker.replace(cc_ca_certs.add_ca_certs, passthrough=False) + self.mock_add = self.mocker.replace(cc_ca_certs.add_ca_certs, + passthrough=False) self.mock_update = self.mocker.replace(cc_ca_certs.update_ca_certs, passthrough=False) - self.mock_remove = self.mocker.replace(cc_ca_certs.remove_default_ca_certs, - passthrough=False) + self.mock_remove = self.mocker.replace( + cc_ca_certs.remove_default_ca_certs, passthrough=False) # Order must be correct self.mocker.order() @@ -183,8 +185,8 @@ class TestRemoveDefaultCaCerts(MockerTestCase): }) def test_commands(self): - mock_delete_dir_contents = self.mocker.replace(util.delete_dir_contents, - passthrough=False) + mock_delete_dir_contents = self.mocker.replace( + util.delete_dir_contents, passthrough=False) mock_write = self.mocker.replace(util.write_file, passthrough=False) mock_subp = self.mocker.replace(util.subp, passthrough=False) diff --git a/tests/unittests/test_userdata.py b/tests/unittests/test_userdata.py index 861642b6..fbbf07f2 100644 --- a/tests/unittests/test_userdata.py +++ b/tests/unittests/test_userdata.py @@ -4,18 +4,14 @@ import StringIO import logging import os -import shutil -import tempfile from email.mime.base import MIMEBase from mocker import MockerTestCase -from cloudinit import helpers from cloudinit import log from cloudinit import sources from cloudinit import stages -from cloudinit import util INSTANCE_ID = "i-testing" diff --git a/tests/unittests/test_util.py b/tests/unittests/test_util.py index 93979f06..19f66cc4 100644 --- a/tests/unittests/test_util.py +++ b/tests/unittests/test_util.py @@ -14,7 +14,7 @@ class FakeSelinux(object): self.match_what = match_what self.restored = [] - def matchpathcon(self, path, mode): + def matchpathcon(self, path, mode): # pylint: disable=W0613 if path == self.match_what: return else: @@ -23,7 +23,7 @@ class FakeSelinux(object): def is_selinux_enabled(self): return True - def restorecon(self, path, recursive): + def restorecon(self, path, recursive): # pylint: disable=W0613 self.restored.append(path) |