summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2013-03-07 14:54:25 -0500
committerScott Moser <smoser@ubuntu.com>2013-03-07 14:54:25 -0500
commitdca9b6c94e10f9f42ad0f129ae6fd38ebb44f4b5 (patch)
tree0b4ac8f1e658e07bda378c75b5fb33940a14265b /tests
parent90ed3dee9672ba2756dd4a303f94e3de47e70404 (diff)
downloadvyos-cloud-init-dca9b6c94e10f9f42ad0f129ae6fd38ebb44f4b5.tar.gz
vyos-cloud-init-dca9b6c94e10f9f42ad0f129ae6fd38ebb44f4b5.zip
pep8 and pylint fixes
Diffstat (limited to 'tests')
-rw-r--r--tests/unittests/helpers.py1
-rw-r--r--tests/unittests/test_datasource/test_nocloud.py2
-rw-r--r--tests/unittests/test_handler/test_handler_growpart.py22
-rw-r--r--tests/unittests/test_sshutil.py5
4 files changed, 16 insertions, 14 deletions
diff --git a/tests/unittests/helpers.py b/tests/unittests/helpers.py
index 91a50e18..904677f1 100644
--- a/tests/unittests/helpers.py
+++ b/tests/unittests/helpers.py
@@ -183,6 +183,7 @@ class FilesystemMockingTestCase(ResourceUsingTestCase):
setattr(mod, f, trap_func)
self.patched_funcs.append((mod, f, func))
+
def populate_dir(path, files):
os.makedirs(path)
for (name, content) in files.iteritems():
diff --git a/tests/unittests/test_datasource/test_nocloud.py b/tests/unittests/test_datasource/test_nocloud.py
index 28e0a472..62fc5358 100644
--- a/tests/unittests/test_datasource/test_nocloud.py
+++ b/tests/unittests/test_datasource/test_nocloud.py
@@ -1,7 +1,7 @@
from cloudinit import helpers
-from tests.unittests.helpers import populate_dir
from cloudinit.sources import DataSourceNoCloud
from cloudinit import util
+from tests.unittests.helpers import populate_dir
from mocker import MockerTestCase
import os
diff --git a/tests/unittests/test_handler/test_handler_growpart.py b/tests/unittests/test_handler/test_handler_growpart.py
index 74c254e0..325244f2 100644
--- a/tests/unittests/test_handler/test_handler_growpart.py
+++ b/tests/unittests/test_handler/test_handler_growpart.py
@@ -1,7 +1,6 @@
from mocker import MockerTestCase
from cloudinit import cloud
-from cloudinit import helpers
from cloudinit import util
from cloudinit.config import cc_growpart
@@ -9,9 +8,7 @@ from cloudinit.config import cc_growpart
import errno
import logging
import os
-import mocker
import re
-import stat
# growpart:
# mode: auto # off, on, auto, 'growpart', 'parted'
@@ -85,6 +82,7 @@ growpart disk partition
Resize partition 1 on /dev/sda
"""
+
class TestDisabled(MockerTestCase):
def setUp(self):
super(TestDisabled, self).setUp()
@@ -106,6 +104,7 @@ class TestDisabled(MockerTestCase):
self.handle(self.name, config, self.cloud_init, self.log, self.args)
+
class TestConfig(MockerTestCase):
def setUp(self):
super(TestConfig, self).setUp()
@@ -125,9 +124,9 @@ class TestConfig(MockerTestCase):
def test_no_resizers_auto_is_fine(self):
subp = self.mocker.replace(util.subp, passthrough=False)
subp(['parted', '--help'], env={'LANG': 'C'})
- self.mocker.result((HELP_PARTED_NO_RESIZE,""))
+ self.mocker.result((HELP_PARTED_NO_RESIZE, ""))
subp(['growpart', '--help'], env={'LANG': 'C'})
- self.mocker.result((HELP_GROWPART_NO_RESIZE,""))
+ self.mocker.result((HELP_GROWPART_NO_RESIZE, ""))
self.mocker.replay()
config = {'growpart': {'mode': 'auto'}}
@@ -136,7 +135,7 @@ class TestConfig(MockerTestCase):
def test_no_resizers_mode_growpart_is_exception(self):
subp = self.mocker.replace(util.subp, passthrough=False)
subp(['growpart', '--help'], env={'LANG': 'C'})
- self.mocker.result((HELP_GROWPART_NO_RESIZE,""))
+ self.mocker.result((HELP_GROWPART_NO_RESIZE, ""))
self.mocker.replay()
config = {'growpart': {'mode': "growpart"}}
@@ -146,7 +145,7 @@ class TestConfig(MockerTestCase):
def test_mode_auto_prefers_parted(self):
subp = self.mocker.replace(util.subp, passthrough=False)
subp(['parted', '--help'], env={'LANG': 'C'})
- self.mocker.result((HELP_PARTED_RESIZE,""))
+ self.mocker.result((HELP_PARTED_RESIZE, ""))
self.mocker.replay()
ret = cc_growpart.resizer_factory(mode="auto")
@@ -173,7 +172,7 @@ class TestConfig(MockerTestCase):
self.handle(self.name, {}, self.cloud_init, self.log, self.args)
finally:
cc_growpart.RESIZERS = orig_resizers
-
+
class TestResize(MockerTestCase):
def setUp(self):
@@ -196,7 +195,7 @@ class TestResize(MockerTestCase):
real_stat = os.stat
resize_calls = []
- class myresizer():
+ class myresizer(object):
def resize(self, diskdev, partnum, partdev):
resize_calls.append((diskdev, partnum, partdev))
if partdev == "/dev/YYda2":
@@ -224,7 +223,7 @@ class TestResize(MockerTestCase):
if f[0] == name:
return f
return None
-
+
self.assertEqual(cc_growpart.RESIZE.NOCHANGE,
find("/dev/XXda1", resized)[1])
self.assertEqual(cc_growpart.RESIZE.CHANGED,
@@ -244,7 +243,8 @@ def simple_device_part_info(devpath):
ret = re.search("([^0-9]*)([0-9]*)$", devpath)
x = (ret.group(1), ret.group(2))
return x
-
+
+
class Bunch:
def __init__(self, **kwds):
self.__dict__.update(kwds)
diff --git a/tests/unittests/test_sshutil.py b/tests/unittests/test_sshutil.py
index 2415d06f..d8662cac 100644
--- a/tests/unittests/test_sshutil.py
+++ b/tests/unittests/test_sshutil.py
@@ -1,5 +1,5 @@
-from unittest import TestCase
from cloudinit import ssh_util
+from unittest import TestCase
VALID_CONTENT = {
@@ -34,6 +34,7 @@ TEST_OPTIONS = ("no-port-forwarding,no-agent-forwarding,no-X11-forwarding,"
'command="echo \'Please login as the user \"ubuntu\" rather than the'
'user \"root\".\';echo;sleep 10"')
+
class TestAuthKeyLineParser(TestCase):
def test_simple_parse(self):
# test key line with common 3 fields (keytype, base64, comment)
@@ -61,7 +62,7 @@ class TestAuthKeyLineParser(TestCase):
self.assertFalse(key.options)
self.assertFalse(key.comment)
self.assertEqual(key.keytype, ktype)
-
+
def test_parse_with_keyoptions(self):
# test key line with options in it
parser = ssh_util.AuthKeyLineParser()