summaryrefslogtreecommitdiff
path: root/tests/unittests
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unittests')
-rw-r--r--tests/unittests/test__init__.py14
-rw-r--r--tests/unittests/test_builtin_handlers.py4
-rw-r--r--tests/unittests/test_datasource/test_altcloud.py99
-rw-r--r--tests/unittests/test_datasource/test_maas.py22
-rw-r--r--tests/unittests/test_handler/test_handler_ca_certs.py18
-rw-r--r--tests/unittests/test_userdata.py13
-rw-r--r--tests/unittests/test_util.py4
7 files changed, 91 insertions, 83 deletions
diff --git a/tests/unittests/test__init__.py b/tests/unittests/test__init__.py
index 464c8c2f..ac082076 100644
--- a/tests/unittests/test__init__.py
+++ b/tests/unittests/test__init__.py
@@ -1,6 +1,6 @@
-import StringIO
import logging
import os
+import StringIO
import sys
from mocker import MockerTestCase, ANY, ARGS, KWARGS
@@ -61,14 +61,14 @@ class TestWalkerHandleHandler(MockerTestCase):
import_mock(self.expected_module_name)
self.mocker.result(self.module_fake)
self.mocker.replay()
-
+
handlers.walker_handle_handler(self.data, self.ctype, self.filename,
self.payload)
-
+
self.assertEqual(1, self.data["handlercount"])
-
+
def test_import_error(self):
- """Module import errors are logged. No handler added to C{pdata}"""
+ """Module import errors are logged. No handler added to C{pdata}."""
import_mock = self.mocker.replace(importer.import_module,
passthrough=False)
import_mock(self.expected_module_name)
@@ -81,7 +81,7 @@ class TestWalkerHandleHandler(MockerTestCase):
self.assertEqual(0, self.data["handlercount"])
def test_attribute_error(self):
- """Attribute errors are logged. No handler added to C{pdata}"""
+ """Attribute errors are logged. No handler added to C{pdata}."""
import_mock = self.mocker.replace(importer.import_module,
passthrough=False)
import_mock(self.expected_module_name)
@@ -156,7 +156,7 @@ class TestHandlerHandlePart(MockerTestCase):
self.payload, self.frequency)
def test_no_handle_when_modfreq_once(self):
- """C{handle_part} is not called if frequency is once"""
+ """C{handle_part} is not called if frequency is once."""
self.frequency = "once"
mod_mock = self.mocker.mock()
getattr(mod_mock, "frequency")
diff --git a/tests/unittests/test_builtin_handlers.py b/tests/unittests/test_builtin_handlers.py
index 5bba8bc9..ebc0bd51 100644
--- a/tests/unittests/test_builtin_handlers.py
+++ b/tests/unittests/test_builtin_handlers.py
@@ -1,4 +1,4 @@
-"""Tests of the built-in user data handlers"""
+"""Tests of the built-in user data handlers."""
import os
@@ -33,7 +33,7 @@ class TestBuiltins(MockerTestCase):
None, None, None)
self.assertEquals(0, len(os.listdir(up_root)))
- def test_upstart_frequency_single(self):
+ def test_upstart_frequency_single(self):
c_root = self.makeDir()
up_root = self.makeDir()
paths = helpers.Paths({
diff --git a/tests/unittests/test_datasource/test_altcloud.py b/tests/unittests/test_datasource/test_altcloud.py
index 54e152e9..bda61c7e 100644
--- a/tests/unittests/test_datasource/test_altcloud.py
+++ b/tests/unittests/test_datasource/test_altcloud.py
@@ -25,14 +25,15 @@ import os
import shutil
import tempfile
-from unittest import TestCase
from cloudinit import helpers
+from unittest import TestCase
# Get the cloudinit.sources.DataSourceAltCloud import items needed.
import cloudinit.sources.DataSourceAltCloud
from cloudinit.sources.DataSourceAltCloud import DataSourceAltCloud
from cloudinit.sources.DataSourceAltCloud import read_user_data_callback
+
def _write_cloud_info_file(value):
'''
Populate the CLOUD_INFO_FILE which would be populated
@@ -44,12 +45,14 @@ def _write_cloud_info_file(value):
cifile.close()
os.chmod(cloudinit.sources.DataSourceAltCloud.CLOUD_INFO_FILE, 0664)
+
def _remove_cloud_info_file():
'''
Remove the test CLOUD_INFO_FILE
'''
os.remove(cloudinit.sources.DataSourceAltCloud.CLOUD_INFO_FILE)
+
def _write_user_data_files(mount_dir, value):
'''
Populate the deltacloud_user_data_file the user_data_file
@@ -68,6 +71,7 @@ def _write_user_data_files(mount_dir, value):
udfile.close()
os.chmod(user_data_file, 0664)
+
def _remove_user_data_files(mount_dir,
dc_file=True,
non_dc_file=True):
@@ -91,14 +95,15 @@ def _remove_user_data_files(mount_dir,
except OSError:
pass
+
class TestGetCloudType(TestCase):
'''
- Test to exercise method: DataSourceAltCloud.get_cloud_type()
+ Test to exercise method: DataSourceAltCloud.get_cloud_type()
'''
def setUp(self):
- ''' Set up '''
- self.paths = helpers.Paths({ 'cloud_dir': '/tmp' })
+ '''Set up.'''
+ self.paths = helpers.Paths({'cloud_dir': '/tmp'})
def tearDown(self):
# Reset
@@ -158,14 +163,15 @@ class TestGetCloudType(TestCase):
self.assertEquals('UNKNOWN', \
dsrc.get_cloud_type())
+
class TestGetDataCloudInfoFile(TestCase):
'''
- Test to exercise method: DataSourceAltCloud.get_data()
+ Test to exercise method: DataSourceAltCloud.get_data()
With a contrived CLOUD_INFO_FILE
'''
def setUp(self):
- ''' Set up '''
- self.paths = helpers.Paths({ 'cloud_dir': '/tmp' })
+ '''Set up.'''
+ self.paths = helpers.Paths({'cloud_dir': '/tmp'})
self.cloud_info_file = tempfile.mkstemp()[1]
cloudinit.sources.DataSourceAltCloud.CLOUD_INFO_FILE = \
self.cloud_info_file
@@ -183,52 +189,53 @@ class TestGetDataCloudInfoFile(TestCase):
'/etc/sysconfig/cloud-info'
def test_rhev(self):
- '''Success Test module get_data() forcing RHEV '''
+ '''Success Test module get_data() forcing RHEV.'''
_write_cloud_info_file('RHEV')
dsrc = DataSourceAltCloud({}, None, self.paths)
- dsrc.user_data_rhevm = lambda : True
+ dsrc.user_data_rhevm = lambda: True
self.assertEquals(True, dsrc.get_data())
def test_vsphere(self):
- '''Success Test module get_data() forcing VSPHERE '''
+ '''Success Test module get_data() forcing VSPHERE.'''
_write_cloud_info_file('VSPHERE')
dsrc = DataSourceAltCloud({}, None, self.paths)
- dsrc.user_data_vsphere = lambda : True
+ dsrc.user_data_vsphere = lambda: True
self.assertEquals(True, dsrc.get_data())
def test_fail_rhev(self):
- '''Failure Test module get_data() forcing RHEV '''
+ '''Failure Test module get_data() forcing RHEV.'''
_write_cloud_info_file('RHEV')
dsrc = DataSourceAltCloud({}, None, self.paths)
- dsrc.user_data_rhevm = lambda : False
+ dsrc.user_data_rhevm = lambda: False
self.assertEquals(False, dsrc.get_data())
def test_fail_vsphere(self):
- '''Failure Test module get_data() forcing VSPHERE '''
+ '''Failure Test module get_data() forcing VSPHERE.'''
_write_cloud_info_file('VSPHERE')
dsrc = DataSourceAltCloud({}, None, self.paths)
- dsrc.user_data_vsphere = lambda : False
+ dsrc.user_data_vsphere = lambda: False
self.assertEquals(False, dsrc.get_data())
def test_unrecognized(self):
- '''Failure Test module get_data() forcing unrecognized '''
+ '''Failure Test module get_data() forcing unrecognized.'''
_write_cloud_info_file('unrecognized')
dsrc = DataSourceAltCloud({}, None, self.paths)
self.assertEquals(False, dsrc.get_data())
+
class TestGetDataNoCloudInfoFile(TestCase):
'''
- Test to exercise method: DataSourceAltCloud.get_data()
+ Test to exercise method: DataSourceAltCloud.get_data()
Without a CLOUD_INFO_FILE
'''
def setUp(self):
- ''' Set up '''
- self.paths = helpers.Paths({ 'cloud_dir': '/tmp' })
+ '''Set up.'''
+ self.paths = helpers.Paths({'cloud_dir': '/tmp'})
cloudinit.sources.DataSourceAltCloud.CLOUD_INFO_FILE = \
'no such file'
@@ -240,38 +247,39 @@ class TestGetDataNoCloudInfoFile(TestCase):
['dmidecode', '--string', 'system-product-name']
def test_rhev_no_cloud_file(self):
- '''Test No cloud info file module get_data() forcing RHEV '''
+ '''Test No cloud info file module get_data() forcing RHEV.'''
cloudinit.sources.DataSourceAltCloud.CMD_DMI_SYSTEM = \
['echo', 'RHEV Hypervisor']
dsrc = DataSourceAltCloud({}, None, self.paths)
- dsrc.user_data_rhevm = lambda : True
+ dsrc.user_data_rhevm = lambda: True
self.assertEquals(True, dsrc.get_data())
def test_vsphere_no_cloud_file(self):
- '''Test No cloud info file module get_data() forcing VSPHERE '''
+ '''Test No cloud info file module get_data() forcing VSPHERE.'''
cloudinit.sources.DataSourceAltCloud.CMD_DMI_SYSTEM = \
['echo', 'VMware Virtual Platform']
dsrc = DataSourceAltCloud({}, None, self.paths)
- dsrc.user_data_vsphere = lambda : True
+ dsrc.user_data_vsphere = lambda: True
self.assertEquals(True, dsrc.get_data())
def test_failure_no_cloud_file(self):
- '''Test No cloud info file module get_data() forcing unrecognized '''
+ '''Test No cloud info file module get_data() forcing unrecognized.'''
cloudinit.sources.DataSourceAltCloud.CMD_DMI_SYSTEM = \
['echo', 'Unrecognized Platform']
dsrc = DataSourceAltCloud({}, None, self.paths)
self.assertEquals(False, dsrc.get_data())
+
class TestUserDataRhevm(TestCase):
'''
- Test to exercise method: DataSourceAltCloud.user_data_rhevm()
+ Test to exercise method: DataSourceAltCloud.user_data_rhevm()
'''
def setUp(self):
- ''' Set up '''
- self.paths = helpers.Paths({ 'cloud_dir': '/tmp' })
+ '''Set up.'''
+ self.paths = helpers.Paths({'cloud_dir': '/tmp'})
self.mount_dir = tempfile.mkdtemp()
_write_user_data_files(self.mount_dir, 'test user data')
@@ -295,7 +303,7 @@ class TestUserDataRhevm(TestCase):
['/sbin/udevadm', 'settle', '--quiet', '--timeout=5']
def test_mount_cb_fails(self):
- '''Test user_data_rhevm() where mount_cb fails'''
+ '''Test user_data_rhevm() where mount_cb fails.'''
cloudinit.sources.DataSourceAltCloud.CMD_PROBE_FLOPPY = \
['echo', 'modprobe floppy']
@@ -305,7 +313,7 @@ class TestUserDataRhevm(TestCase):
self.assertEquals(False, dsrc.user_data_rhevm())
def test_modprobe_fails(self):
- '''Test user_data_rhevm() where modprobe fails. '''
+ '''Test user_data_rhevm() where modprobe fails.'''
cloudinit.sources.DataSourceAltCloud.CMD_PROBE_FLOPPY = \
['ls', 'modprobe floppy']
@@ -315,7 +323,7 @@ class TestUserDataRhevm(TestCase):
self.assertEquals(False, dsrc.user_data_rhevm())
def test_no_modprobe_cmd(self):
- '''Test user_data_rhevm() with no modprobe command. '''
+ '''Test user_data_rhevm() with no modprobe command.'''
cloudinit.sources.DataSourceAltCloud.CMD_PROBE_FLOPPY = \
['bad command', 'modprobe floppy']
@@ -325,7 +333,7 @@ class TestUserDataRhevm(TestCase):
self.assertEquals(False, dsrc.user_data_rhevm())
def test_udevadm_fails(self):
- '''Test user_data_rhevm() where udevadm fails. '''
+ '''Test user_data_rhevm() where udevadm fails.'''
cloudinit.sources.DataSourceAltCloud.CMD_UDEVADM_SETTLE = \
['ls', 'udevadm floppy']
@@ -335,7 +343,7 @@ class TestUserDataRhevm(TestCase):
self.assertEquals(False, dsrc.user_data_rhevm())
def test_no_udevadm_cmd(self):
- '''Test user_data_rhevm() with no udevadm command. '''
+ '''Test user_data_rhevm() with no udevadm command.'''
cloudinit.sources.DataSourceAltCloud.CMD_UDEVADM_SETTLE = \
['bad command', 'udevadm floppy']
@@ -344,13 +352,14 @@ class TestUserDataRhevm(TestCase):
self.assertEquals(False, dsrc.user_data_rhevm())
+
class TestUserDataVsphere(TestCase):
'''
- Test to exercise method: DataSourceAltCloud.user_data_vsphere()
+ Test to exercise method: DataSourceAltCloud.user_data_vsphere()
'''
def setUp(self):
- ''' Set up '''
- self.paths = helpers.Paths({ 'cloud_dir': '/tmp' })
+ '''Set up.'''
+ self.paths = helpers.Paths({'cloud_dir': '/tmp'})
self.mount_dir = tempfile.mkdtemp()
_write_user_data_files(self.mount_dir, 'test user data')
@@ -370,7 +379,7 @@ class TestUserDataVsphere(TestCase):
'/etc/sysconfig/cloud-info'
def test_user_data_vsphere(self):
- '''Test user_data_vsphere() where mount_cb fails'''
+ '''Test user_data_vsphere() where mount_cb fails.'''
cloudinit.sources.DataSourceAltCloud.MEDIA_DIR = self.mount_dir
@@ -378,13 +387,14 @@ class TestUserDataVsphere(TestCase):
self.assertEquals(False, dsrc.user_data_vsphere())
+
class TestReadUserDataCallback(TestCase):
'''
- Test to exercise method: DataSourceAltCloud.read_user_data_callback()
+ Test to exercise method: DataSourceAltCloud.read_user_data_callback()
'''
def setUp(self):
- ''' Set up '''
- self.paths = helpers.Paths({ 'cloud_dir': '/tmp' })
+ '''Set up.'''
+ self.paths = helpers.Paths({'cloud_dir': '/tmp'})
self.mount_dir = tempfile.mkdtemp()
_write_user_data_files(self.mount_dir, 'test user data')
@@ -400,15 +410,14 @@ class TestReadUserDataCallback(TestCase):
except OSError:
pass
-
def test_callback_both(self):
- '''Test read_user_data_callback() with both files'''
+ '''Test read_user_data_callback() with both files.'''
self.assertEquals('test user data',
read_user_data_callback(self.mount_dir))
def test_callback_dc(self):
- '''Test read_user_data_callback() with only DC file'''
+ '''Test read_user_data_callback() with only DC file.'''
_remove_user_data_files(self.mount_dir,
dc_file=False,
@@ -418,7 +427,7 @@ class TestReadUserDataCallback(TestCase):
read_user_data_callback(self.mount_dir))
def test_callback_non_dc(self):
- '''Test read_user_data_callback() with only non-DC file'''
+ '''Test read_user_data_callback() with only non-DC file.'''
_remove_user_data_files(self.mount_dir,
dc_file=True,
@@ -428,9 +437,9 @@ class TestReadUserDataCallback(TestCase):
read_user_data_callback(self.mount_dir))
def test_callback_none(self):
- '''Test read_user_data_callback() no files are found'''
+ '''Test read_user_data_callback() no files are found.'''
- _remove_user_data_files(self.mount_dir)
+ _remove_user_data_files(self.mount_dir)
self.assertEquals(None, read_user_data_callback(self.mount_dir))
# vi: ts=4 expandtab
diff --git a/tests/unittests/test_datasource/test_maas.py b/tests/unittests/test_datasource/test_maas.py
index 8a155f39..85e6add0 100644
--- a/tests/unittests/test_datasource/test_maas.py
+++ b/tests/unittests/test_datasource/test_maas.py
@@ -1,8 +1,8 @@
-import os
from copy import copy
+import os
-from cloudinit import url_helper
from cloudinit.sources import DataSourceMAAS
+from cloudinit import url_helper
from mocker import MockerTestCase
@@ -15,7 +15,7 @@ class TestMAASDataSource(MockerTestCase):
self.tmp = self.makeDir()
def test_seed_dir_valid(self):
- """Verify a valid seeddir is read as such"""
+ """Verify a valid seeddir is read as such."""
data = {'instance-id': 'i-valid01',
'local-hostname': 'valid01-hostname',
@@ -35,7 +35,7 @@ class TestMAASDataSource(MockerTestCase):
self.assertFalse(('user-data' in metadata))
def test_seed_dir_valid_extra(self):
- """Verify extra files do not affect seed_dir validity """
+ """Verify extra files do not affect seed_dir validity."""
data = {'instance-id': 'i-valid-extra',
'local-hostname': 'valid-extra-hostname',
@@ -54,7 +54,7 @@ class TestMAASDataSource(MockerTestCase):
self.assertFalse(('foo' in metadata))
def test_seed_dir_invalid(self):
- """Verify that invalid seed_dir raises MAASSeedDirMalformed"""
+ """Verify that invalid seed_dir raises MAASSeedDirMalformed."""
valid = {'instance-id': 'i-instanceid',
'local-hostname': 'test-hostname', 'user-data': ''}
@@ -78,20 +78,20 @@ class TestMAASDataSource(MockerTestCase):
DataSourceMAAS.read_maas_seed_dir, my_d)
def test_seed_dir_none(self):
- """Verify that empty seed_dir raises MAASSeedDirNone"""
+ """Verify that empty seed_dir raises MAASSeedDirNone."""
my_d = os.path.join(self.tmp, "valid_empty")
self.assertRaises(DataSourceMAAS.MAASSeedDirNone,
DataSourceMAAS.read_maas_seed_dir, my_d)
def test_seed_dir_missing(self):
- """Verify that missing seed_dir raises MAASSeedDirNone"""
- self.assertRaises(DataSourceMAAS.MAASSeedDirNone,
+ """Verify that missing seed_dir raises MAASSeedDirNone."""
+ self.assertRaises(DataSourceMAAS.MAASSeedDirNone,
DataSourceMAAS.read_maas_seed_dir,
os.path.join(self.tmp, "nonexistantdirectory"))
def test_seed_url_valid(self):
- """Verify that valid seed_url is read as such"""
+ """Verify that valid seed_url is read as such."""
valid = {'meta-data/instance-id': 'i-instanceid',
'meta-data/local-hostname': 'test-hostname',
'meta-data/public-keys': 'test-hostname',
@@ -129,11 +129,11 @@ class TestMAASDataSource(MockerTestCase):
valid['meta-data/local-hostname'])
def test_seed_url_invalid(self):
- """Verify that invalid seed_url raises MAASSeedDirMalformed"""
+ """Verify that invalid seed_url raises MAASSeedDirMalformed."""
pass
def test_seed_url_missing(self):
- """Verify seed_url with no found entries raises MAASSeedDirNone"""
+ """Verify seed_url with no found entries raises MAASSeedDirNone."""
pass
diff --git a/tests/unittests/test_handler/test_handler_ca_certs.py b/tests/unittests/test_handler/test_handler_ca_certs.py
index 948de4c4..d3df5c50 100644
--- a/tests/unittests/test_handler/test_handler_ca_certs.py
+++ b/tests/unittests/test_handler/test_handler_ca_certs.py
@@ -1,8 +1,8 @@
from mocker import MockerTestCase
-from cloudinit import util
from cloudinit import cloud
from cloudinit import helpers
+from cloudinit import util
from cloudinit.config import cc_ca_certs
@@ -64,7 +64,7 @@ class TestConfig(MockerTestCase):
cc_ca_certs.handle(self.name, config, self.cloud, self.log, self.args)
def test_empty_trusted_list(self):
- """Test that no certificate are written if 'trusted' list is empty"""
+ """Test that no certificate are written if 'trusted' list is empty."""
config = {"ca-certs": {"trusted": []}}
# No functions should be called
@@ -74,7 +74,7 @@ class TestConfig(MockerTestCase):
cc_ca_certs.handle(self.name, config, self.cloud, self.log, self.args)
def test_single_trusted(self):
- """Test that a single cert gets passed to add_ca_certs"""
+ """Test that a single cert gets passed to add_ca_certs."""
config = {"ca-certs": {"trusted": ["CERT1"]}}
self.mock_add(self.paths, ["CERT1"])
@@ -84,7 +84,7 @@ class TestConfig(MockerTestCase):
cc_ca_certs.handle(self.name, config, self.cloud, self.log, self.args)
def test_multiple_trusted(self):
- """Test that multiple certs get passed to add_ca_certs"""
+ """Test that multiple certs get passed to add_ca_certs."""
config = {"ca-certs": {"trusted": ["CERT1", "CERT2"]}}
self.mock_add(self.paths, ["CERT1", "CERT2"])
@@ -94,7 +94,7 @@ class TestConfig(MockerTestCase):
cc_ca_certs.handle(self.name, config, self.cloud, self.log, self.args)
def test_remove_default_ca_certs(self):
- """Test remove_defaults works as expected"""
+ """Test remove_defaults works as expected."""
config = {"ca-certs": {"remove-defaults": True}}
self.mock_remove(self.paths)
@@ -104,7 +104,7 @@ class TestConfig(MockerTestCase):
cc_ca_certs.handle(self.name, config, self.cloud, self.log, self.args)
def test_no_remove_defaults_if_false(self):
- """Test remove_defaults is not called when config value is False"""
+ """Test remove_defaults is not called when config value is False."""
config = {"ca-certs": {"remove-defaults": False}}
self.mock_update()
@@ -113,7 +113,7 @@ class TestConfig(MockerTestCase):
cc_ca_certs.handle(self.name, config, self.cloud, self.log, self.args)
def test_correct_order_for_remove_then_add(self):
- """Test remove_defaults is not called when config value is False"""
+ """Test remove_defaults is not called when config value is False."""
config = {"ca-certs": {"remove-defaults": True, "trusted": ["CERT1"]}}
self.mock_remove(self.paths)
@@ -139,7 +139,7 @@ class TestAddCaCerts(MockerTestCase):
cc_ca_certs.add_ca_certs(self.paths, [])
def test_single_cert(self):
- """Test adding a single certificate to the trusted CAs"""
+ """Test adding a single certificate to the trusted CAs."""
cert = "CERT1\nLINE2\nLINE3"
mock_write = self.mocker.replace(util.write_file, passthrough=False)
@@ -152,7 +152,7 @@ class TestAddCaCerts(MockerTestCase):
cc_ca_certs.add_ca_certs(self.paths, [cert])
def test_multiple_certs(self):
- """Test adding multiple certificates to the trusted CAs"""
+ """Test adding multiple certificates to the trusted CAs."""
certs = ["CERT1\nLINE2\nLINE3", "CERT2\nLINE2\nLINE3"]
expected_cert_file = "\n".join(certs)
diff --git a/tests/unittests/test_userdata.py b/tests/unittests/test_userdata.py
index fbbf07f2..82a4c555 100644
--- a/tests/unittests/test_userdata.py
+++ b/tests/unittests/test_userdata.py
@@ -1,4 +1,4 @@
-"""Tests for handling of userdata within cloud init"""
+"""Tests for handling of userdata within cloud init."""
import StringIO
@@ -54,7 +54,7 @@ class TestConsumeUserData(MockerTestCase):
return log_file
def test_unhandled_type_warning(self):
- """Raw text without magic is ignored but shows warning"""
+ """Raw text without magic is ignored but shows warning."""
ci = stages.Init()
data = "arbitrary text\n"
ci.datasource = FakeDataSource(data)
@@ -70,7 +70,7 @@ class TestConsumeUserData(MockerTestCase):
log_file.getvalue())
def test_mime_text_plain(self):
- """Mime message of type text/plain is ignored but shows warning"""
+ """Mime message of type text/plain is ignored but shows warning."""
ci = stages.Init()
message = MIMEBase("text", "plain")
message.set_payload("Just text")
@@ -86,9 +86,8 @@ class TestConsumeUserData(MockerTestCase):
"Unhandled unknown content-type (text/plain)",
log_file.getvalue())
-
def test_shellscript(self):
- """Raw text starting #!/bin/sh is treated as script"""
+ """Raw text starting #!/bin/sh is treated as script."""
ci = stages.Init()
script = "#!/bin/sh\necho hello\n"
ci.datasource = FakeDataSource(script)
@@ -104,7 +103,7 @@ class TestConsumeUserData(MockerTestCase):
self.assertEqual("", log_file.getvalue())
def test_mime_text_x_shellscript(self):
- """Mime message of type text/x-shellscript is treated as script"""
+ """Mime message of type text/x-shellscript is treated as script."""
ci = stages.Init()
script = "#!/bin/sh\necho hello\n"
message = MIMEBase("text", "x-shellscript")
@@ -122,7 +121,7 @@ class TestConsumeUserData(MockerTestCase):
self.assertEqual("", log_file.getvalue())
def test_mime_text_plain_shell(self):
- """Mime type text/plain starting #!/bin/sh is treated as script"""
+ """Mime type text/plain starting #!/bin/sh is treated as script."""
ci = stages.Init()
script = "#!/bin/sh\necho hello\n"
message = MIMEBase("text", "plain")
diff --git a/tests/unittests/test_util.py b/tests/unittests/test_util.py
index 19f66cc4..15fcbd26 100644
--- a/tests/unittests/test_util.py
+++ b/tests/unittests/test_util.py
@@ -1,11 +1,11 @@
import os
import stat
-from unittest import TestCase
from mocker import MockerTestCase
+from unittest import TestCase
-from cloudinit import util
from cloudinit import importer
+from cloudinit import util
class FakeSelinux(object):