diff options
author | Mike Milner <mike.milner@canonical.com> | 2012-01-17 13:35:31 -0400 |
---|---|---|
committer | Mike Milner <mike.milner@canonical.com> | 2012-01-17 13:35:31 -0400 |
commit | f52ffe2dda01dd0314523fcac559e6f3fbb3578e (patch) | |
tree | bdc11f80cc0212b1f91adec044769c5beb3975fc /tests | |
parent | 93b733862c1f5f41a5597aa640c434610ad76231 (diff) | |
download | vyos-cloud-init-f52ffe2dda01dd0314523fcac559e6f3fbb3578e.tar.gz vyos-cloud-init-f52ffe2dda01dd0314523fcac559e6f3fbb3578e.zip |
Lint fixes.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unittests/test_handler_ca_certs.py | 22 | ||||
-rw-r--r-- | tests/unittests/test_util.py | 7 |
2 files changed, 19 insertions, 10 deletions
diff --git a/tests/unittests/test_handler_ca_certs.py b/tests/unittests/test_handler_ca_certs.py index 92460088..c289a4f6 100644 --- a/tests/unittests/test_handler_ca_certs.py +++ b/tests/unittests/test_handler_ca_certs.py @@ -1,8 +1,8 @@ -from unittest import TestCase from mocker import MockerTestCase from cloudinit.util import write_file, delete_dir_contents -from cloudinit.CloudConfig.cc_ca_certs import handle, update_ca_certs, add_ca_certs, remove_default_ca_certs +from cloudinit.CloudConfig.cc_ca_certs import ( + handle, update_ca_certs, add_ca_certs, remove_default_ca_certs) class TestNoConfig(MockerTestCase): @@ -36,8 +36,10 @@ class TestConfig(MockerTestCase): # Mock out the functions that actually modify the system self.mock_add = self.mocker.replace(add_ca_certs, passthrough=False) - self.mock_update = self.mocker.replace(update_ca_certs, passthrough=False) - self.mock_remove = self.mocker.replace(remove_default_ca_certs, passthrough=False) + self.mock_update = self.mocker.replace(update_ca_certs, + passthrough=False) + self.mock_remove = self.mocker.replace(remove_default_ca_certs, + passthrough=False) # Order must be correct self.mocker.order() @@ -118,7 +120,7 @@ class TestConfig(MockerTestCase): class TestAddCaCerts(MockerTestCase): def test_no_certs_in_list(self): """Test that no certificate are written if not provided.""" - mock = self.mocker.replace(write_file, passthrough=False) + self.mocker.replace(write_file, passthrough=False) self.mocker.replay() add_ca_certs([]) @@ -130,7 +132,8 @@ class TestAddCaCerts(MockerTestCase): mock_write = self.mocker.replace(write_file, passthrough=False) mock_write("/usr/share/ca-certificates/cloud-init-ca-certs.crt", cert, mode=0644) - mock_write("/etc/ca-certificates.conf", "\ncloud-init-ca-certs.crt", omode="a") + mock_write("/etc/ca-certificates.conf", + "\ncloud-init-ca-certs.crt", omode="a") self.mocker.replay() add_ca_certs([cert]) @@ -143,7 +146,8 @@ class TestAddCaCerts(MockerTestCase): mock_write = self.mocker.replace(write_file, passthrough=False) mock_write("/usr/share/ca-certificates/cloud-init-ca-certs.crt", expected_cert_file, mode=0644) - mock_write("/etc/ca-certificates.conf", "\ncloud-init-ca-certs.crt", omode="a") + mock_write("/etc/ca-certificates.conf", + "\ncloud-init-ca-certs.crt", omode="a") self.mocker.replay() add_ca_certs(certs) @@ -161,13 +165,13 @@ class TestUpdateCaCerts(MockerTestCase): class TestRemoveDefaultCaCerts(MockerTestCase): def test_commands(self): - mock_delete_dir_contents = self.mocker.replace(delete_dir_contents, passthrough=False) + mock_delete_dir_contents = self.mocker.replace(delete_dir_contents, + passthrough=False) mock_write = self.mocker.replace(write_file, passthrough=False) mock_delete_dir_contents("/usr/share/ca-certificates/") mock_delete_dir_contents("/etc/ssl/certs/") mock_write("/etc/ca-certificates.conf", "", mode=0644) - self.mocker.replay() remove_default_ca_certs() diff --git a/tests/unittests/test_util.py b/tests/unittests/test_util.py index f2b2ee3d..d8da8bc9 100644 --- a/tests/unittests/test_util.py +++ b/tests/unittests/test_util.py @@ -5,7 +5,9 @@ from shutil import rmtree import os import stat -from cloudinit.util import mergedict, get_cfg_option_list_or_str, write_file, delete_dir_contents +from cloudinit.util import (mergedict, get_cfg_option_list_or_str, write_file, + delete_dir_contents) + class TestMergeDict(TestCase): def test_simple_merge(self): @@ -65,6 +67,7 @@ class TestMergeDict(TestCase): result = mergedict(source, candidate) self.assertEqual(source, result) + class TestGetCfgOptionListOrStr(TestCase): def test_not_found_no_default(self): """None is returned if key is not found and no default given.""" @@ -96,6 +99,7 @@ class TestGetCfgOptionListOrStr(TestCase): result = get_cfg_option_list_or_str(config, "key") self.assertEqual([], result) + class TestWriteFile(MockerTestCase): def setUp(self): super(TestWriteFile, self).setUp() @@ -174,6 +178,7 @@ class TestWriteFile(MockerTestCase): write_file(path, contents) + class TestDeleteDirContents(TestCase): def setUp(self): super(TestDeleteDirContents, self).setUp() |