summaryrefslogtreecommitdiff
path: root/tests/unittests/test_handler
diff options
context:
space:
mode:
authorChristian Ehrhardt <christian.ehrhardt@canonical.com>2016-05-24 17:58:18 +0200
committerChristian Ehrhardt <christian.ehrhardt@canonical.com>2016-05-24 17:58:18 +0200
commit81156aa423309c72f17709eea994e7e06ebc431c (patch)
tree4ee78fb024c5f03a3c12e39e1adfc1b0cb84063b /tests/unittests/test_handler
parent14040a9c8df6e8406acb79fd653873bb05cb4d40 (diff)
parentea4bc2c603a9d964a918e01d00e39a851e979830 (diff)
downloadvyos-cloud-init-81156aa423309c72f17709eea994e7e06ebc431c.tar.gz
vyos-cloud-init-81156aa423309c72f17709eea994e7e06ebc431c.zip
rebased with upstream and reolved merge conflicts
Diffstat (limited to 'tests/unittests/test_handler')
-rw-r--r--tests/unittests/test_handler/test_handler_apt_configure.py2
-rw-r--r--tests/unittests/test_handler/test_handler_ca_certs.py14
-rw-r--r--tests/unittests/test_handler/test_handler_chef.py14
-rw-r--r--tests/unittests/test_handler/test_handler_growpart.py2
-rw-r--r--tests/unittests/test_handler/test_handler_locale.py2
-rw-r--r--tests/unittests/test_handler/test_handler_lxd.py22
-rw-r--r--tests/unittests/test_handler/test_handler_power_state.py2
-rw-r--r--tests/unittests/test_handler/test_handler_rsyslog.py2
-rw-r--r--tests/unittests/test_handler/test_handler_seed_random.py12
-rw-r--r--tests/unittests/test_handler/test_handler_set_hostname.py16
-rw-r--r--tests/unittests/test_handler/test_handler_snappy.py1
-rw-r--r--tests/unittests/test_handler/test_handler_timezone.py10
-rw-r--r--tests/unittests/test_handler/test_handler_write_files.py4
-rw-r--r--tests/unittests/test_handler/test_handler_yum_add_repo.py13
14 files changed, 52 insertions, 64 deletions
diff --git a/tests/unittests/test_handler/test_handler_apt_configure.py b/tests/unittests/test_handler/test_handler_apt_configure.py
index 1ed185ca..d1dca2c4 100644
--- a/tests/unittests/test_handler/test_handler_apt_configure.py
+++ b/tests/unittests/test_handler/test_handler_apt_configure.py
@@ -1,6 +1,6 @@
+from cloudinit.config import cc_apt_configure
from cloudinit import util
-from cloudinit.config import cc_apt_configure
from ..helpers import TestCase
import os
diff --git a/tests/unittests/test_handler/test_handler_ca_certs.py b/tests/unittests/test_handler/test_handler_ca_certs.py
index a6b9c0fd..5e771731 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 cloudinit import cloud
+from cloudinit.config import cc_ca_certs
from cloudinit import helpers
from cloudinit import util
-from cloudinit.config import cc_ca_certs
from ..helpers import TestCase
import logging
@@ -176,8 +176,7 @@ class TestAddCaCerts(TestCase):
mock_write.assert_has_calls([
mock.call("/usr/share/ca-certificates/cloud-init-ca-certs.crt",
cert, mode=0o644),
- mock.call("/etc/ca-certificates.conf", expected, omode="wb"),
- ])
+ mock.call("/etc/ca-certificates.conf", expected, omode="wb")])
mock_load.assert_called_once_with("/etc/ca-certificates.conf")
def test_single_cert_no_trailing_cr(self):
@@ -202,8 +201,7 @@ class TestAddCaCerts(TestCase):
mock.call("/etc/ca-certificates.conf",
"%s\n%s\n" % (ca_certs_content,
"cloud-init-ca-certs.crt"),
- omode="wb"),
- ])
+ omode="wb")])
mock_load.assert_called_once_with("/etc/ca-certificates.conf")
@@ -228,8 +226,7 @@ class TestAddCaCerts(TestCase):
mock.call("/etc/ca-certificates.conf",
"%s\n%s\n" % (ca_certs_content,
"cloud-init-ca-certs.crt"),
- omode='wb'),
- ])
+ omode='wb')])
mock_load.assert_called_once_with("/etc/ca-certificates.conf")
@@ -264,8 +261,7 @@ class TestRemoveDefaultCaCerts(TestCase):
mock_delete.assert_has_calls([
mock.call("/usr/share/ca-certificates/"),
- mock.call("/etc/ssl/certs/"),
- ])
+ mock.call("/etc/ssl/certs/")])
mock_write.assert_called_once_with(
"/etc/ca-certificates.conf", "", mode=0o644)
diff --git a/tests/unittests/test_handler/test_handler_chef.py b/tests/unittests/test_handler/test_handler_chef.py
index 7763f23b..7a1bc317 100644
--- a/tests/unittests/test_handler/test_handler_chef.py
+++ b/tests/unittests/test_handler/test_handler_chef.py
@@ -1,21 +1,19 @@
import json
+import logging
import os
-
-from cloudinit.config import cc_chef
+import shutil
+import six
+import tempfile
from cloudinit import cloud
+from cloudinit.config import cc_chef
from cloudinit import distros
from cloudinit import helpers
-from cloudinit import util
from cloudinit.sources import DataSourceNone
+from cloudinit import util
from .. import helpers as t_help
-import six
-import logging
-import shutil
-import tempfile
-
LOG = logging.getLogger(__name__)
CLIENT_TEMPL = os.path.sep.join(["templates", "chef_client.rb.tmpl"])
diff --git a/tests/unittests/test_handler/test_handler_growpart.py b/tests/unittests/test_handler/test_handler_growpart.py
index bef0d80d..e653488a 100644
--- a/tests/unittests/test_handler/test_handler_growpart.py
+++ b/tests/unittests/test_handler/test_handler_growpart.py
@@ -1,7 +1,7 @@
from cloudinit import cloud
+from cloudinit.config import cc_growpart
from cloudinit import util
-from cloudinit.config import cc_growpart
from ..helpers import TestCase
import errno
diff --git a/tests/unittests/test_handler/test_handler_locale.py b/tests/unittests/test_handler/test_handler_locale.py
index de85eff6..c91908f4 100644
--- a/tests/unittests/test_handler/test_handler_locale.py
+++ b/tests/unittests/test_handler/test_handler_locale.py
@@ -64,4 +64,4 @@ class TestLocale(t_help.FilesystemMockingTestCase):
contents = util.load_file('/etc/sysconfig/language', decode=False)
n_cfg = ConfigObj(BytesIO(contents))
- self.assertEquals({'RC_LANG': cfg['locale']}, dict(n_cfg))
+ self.assertEqual({'RC_LANG': cfg['locale']}, dict(n_cfg))
diff --git a/tests/unittests/test_handler/test_handler_lxd.py b/tests/unittests/test_handler/test_handler_lxd.py
index 5f61ba6a..6f90defb 100644
--- a/tests/unittests/test_handler/test_handler_lxd.py
+++ b/tests/unittests/test_handler/test_handler_lxd.py
@@ -1,6 +1,6 @@
from cloudinit.config import cc_lxd
-from cloudinit import (distros, helpers, cloud)
from cloudinit.sources import DataSourceNoCloud
+from cloudinit import (distros, helpers, cloud)
from .. import helpers as t_help
import logging
@@ -42,11 +42,11 @@ class TestLxd(t_help.TestCase):
cc_lxd.handle('cc_lxd', self.lxd_cfg, cc, LOG, [])
self.assertTrue(mock_util.which.called)
init_call = mock_util.subp.call_args_list[0][0][0]
- self.assertEquals(init_call,
- ['lxd', 'init', '--auto',
- '--network-address=0.0.0.0',
- '--storage-backend=zfs',
- '--storage-pool=poolname'])
+ self.assertEqual(init_call,
+ ['lxd', 'init', '--auto',
+ '--network-address=0.0.0.0',
+ '--storage-backend=zfs',
+ '--storage-pool=poolname'])
@mock.patch("cloudinit.config.cc_lxd.util")
def test_lxd_install(self, mock_util):
@@ -56,7 +56,7 @@ class TestLxd(t_help.TestCase):
cc_lxd.handle('cc_lxd', self.lxd_cfg, cc, LOG, [])
self.assertTrue(cc.distro.install_packages.called)
install_pkg = cc.distro.install_packages.call_args_list[0][0][0]
- self.assertEquals(sorted(install_pkg), ['lxd', 'zfs'])
+ self.assertEqual(sorted(install_pkg), ['lxd', 'zfs'])
@mock.patch("cloudinit.config.cc_lxd.util")
def test_no_init_does_nothing(self, mock_util):
@@ -87,7 +87,7 @@ class TestLxd(t_help.TestCase):
"ipv6_netmask": "64",
"ipv6_nat": "true",
"domain": "lxd"}
- self.assertEquals(
+ self.assertEqual(
cc_lxd.bridge_to_debconf(data),
{"lxd/setup-bridge": "true",
"lxd/bridge-name": "testbr0",
@@ -109,7 +109,7 @@ class TestLxd(t_help.TestCase):
"ipv6_address": "fd98:9e0:3744::1",
"ipv6_netmask": "64",
"ipv6_nat": "true"}
- self.assertEquals(
+ self.assertEqual(
cc_lxd.bridge_to_debconf(data),
{"lxd/setup-bridge": "true",
"lxd/bridge-ipv6": "true",
@@ -120,7 +120,7 @@ class TestLxd(t_help.TestCase):
def test_lxd_debconf_existing(self):
data = {"mode": "existing",
"name": "testbr0"}
- self.assertEquals(
+ self.assertEqual(
cc_lxd.bridge_to_debconf(data),
{"lxd/setup-bridge": "false",
"lxd/use-existing-bridge": "true",
@@ -128,7 +128,7 @@ class TestLxd(t_help.TestCase):
def test_lxd_debconf_none(self):
data = {"mode": "none"}
- self.assertEquals(
+ self.assertEqual(
cc_lxd.bridge_to_debconf(data),
{"lxd/setup-bridge": "false",
"lxd/bridge-name": ""})
diff --git a/tests/unittests/test_handler/test_handler_power_state.py b/tests/unittests/test_handler/test_handler_power_state.py
index 04ce5687..feff319d 100644
--- a/tests/unittests/test_handler/test_handler_power_state.py
+++ b/tests/unittests/test_handler/test_handler_power_state.py
@@ -119,7 +119,7 @@ def check_lps_ret(psc_return, mode=None):
try:
float(timeout)
- except:
+ except Exception:
errs.append("timeout failed convert to float")
if len(errs):
diff --git a/tests/unittests/test_handler/test_handler_rsyslog.py b/tests/unittests/test_handler/test_handler_rsyslog.py
index b932165c..38636063 100644
--- a/tests/unittests/test_handler/test_handler_rsyslog.py
+++ b/tests/unittests/test_handler/test_handler_rsyslog.py
@@ -31,7 +31,7 @@ class TestLoadConfig(t_help.TestCase):
'config_dir': "mydir",
'config_filename': 'myfilename',
'service_reload_command': 'auto'}
- )
+ )
self.assertEqual(found, self.basecfg)
diff --git a/tests/unittests/test_handler/test_handler_seed_random.py b/tests/unittests/test_handler/test_handler_seed_random.py
index 98bc9b81..a0390da9 100644
--- a/tests/unittests/test_handler/test_handler_seed_random.py
+++ b/tests/unittests/test_handler/test_handler_seed_random.py
@@ -92,7 +92,7 @@ class TestRandomSeed(t_help.TestCase):
}
cc_seed_random.handle('test', cfg, self._get_cloud('ubuntu'), LOG, [])
contents = util.load_file(self._seed_file)
- self.assertEquals("tiny-tim-was-here", contents)
+ self.assertEqual("tiny-tim-was-here", contents)
def test_append_random_unknown_encoding(self):
data = self._compress(b"tiny-toe")
@@ -117,7 +117,7 @@ class TestRandomSeed(t_help.TestCase):
}
cc_seed_random.handle('test', cfg, self._get_cloud('ubuntu'), LOG, [])
contents = util.load_file(self._seed_file)
- self.assertEquals("tiny-toe", contents)
+ self.assertEqual("tiny-toe", contents)
def test_append_random_gz(self):
data = self._compress(b"big-toe")
@@ -130,7 +130,7 @@ class TestRandomSeed(t_help.TestCase):
}
cc_seed_random.handle('test', cfg, self._get_cloud('ubuntu'), LOG, [])
contents = util.load_file(self._seed_file)
- self.assertEquals("big-toe", contents)
+ self.assertEqual("big-toe", contents)
def test_append_random_base64(self):
data = util.b64e('bubbles')
@@ -143,7 +143,7 @@ class TestRandomSeed(t_help.TestCase):
}
cc_seed_random.handle('test', cfg, self._get_cloud('ubuntu'), LOG, [])
contents = util.load_file(self._seed_file)
- self.assertEquals("bubbles", contents)
+ self.assertEqual("bubbles", contents)
def test_append_random_b64(self):
data = util.b64e('kit-kat')
@@ -156,7 +156,7 @@ class TestRandomSeed(t_help.TestCase):
}
cc_seed_random.handle('test', cfg, self._get_cloud('ubuntu'), LOG, [])
contents = util.load_file(self._seed_file)
- self.assertEquals("kit-kat", contents)
+ self.assertEqual("kit-kat", contents)
def test_append_random_metadata(self):
cfg = {
@@ -168,7 +168,7 @@ class TestRandomSeed(t_help.TestCase):
c = self._get_cloud('ubuntu', {'random_seed': '-so-was-josh'})
cc_seed_random.handle('test', cfg, c, LOG, [])
contents = util.load_file(self._seed_file)
- self.assertEquals('tiny-tim-was-here-so-was-josh', contents)
+ self.assertEqual('tiny-tim-was-here-so-was-josh', contents)
def test_seed_command_provided_and_available(self):
c = self._get_cloud('ubuntu', {})
diff --git a/tests/unittests/test_handler/test_handler_set_hostname.py b/tests/unittests/test_handler/test_handler_set_hostname.py
index d358b069..7effa124 100644
--- a/tests/unittests/test_handler/test_handler_set_hostname.py
+++ b/tests/unittests/test_handler/test_handler_set_hostname.py
@@ -7,13 +7,11 @@ from cloudinit import util
from .. import helpers as t_help
-import shutil
-import tempfile
+from configobj import ConfigObj
import logging
-
+import shutil
from six import BytesIO
-
-from configobj import ConfigObj
+import tempfile
LOG = logging.getLogger(__name__)
@@ -43,8 +41,8 @@ class TestHostname(t_help.FilesystemMockingTestCase):
if not distro.uses_systemd():
contents = util.load_file("/etc/sysconfig/network", decode=False)
n_cfg = ConfigObj(BytesIO(contents))
- self.assertEquals({'HOSTNAME': 'blah.blah.blah.yahoo.com'},
- dict(n_cfg))
+ self.assertEqual({'HOSTNAME': 'blah.blah.blah.yahoo.com'},
+ dict(n_cfg))
def test_write_hostname_debian(self):
cfg = {
@@ -58,7 +56,7 @@ class TestHostname(t_help.FilesystemMockingTestCase):
cc_set_hostname.handle('cc_set_hostname',
cfg, cc, LOG, [])
contents = util.load_file("/etc/hostname")
- self.assertEquals('blah', contents.strip())
+ self.assertEqual('blah', contents.strip())
def test_write_hostname_sles(self):
cfg = {
@@ -71,4 +69,4 @@ class TestHostname(t_help.FilesystemMockingTestCase):
self.patchUtils(self.tmp)
cc_set_hostname.handle('cc_set_hostname', cfg, cc, LOG, [])
contents = util.load_file("/etc/HOSTNAME")
- self.assertEquals('blah', contents.strip())
+ self.assertEqual('blah', contents.strip())
diff --git a/tests/unittests/test_handler/test_handler_snappy.py b/tests/unittests/test_handler/test_handler_snappy.py
index 8aeff53c..57dce1bc 100644
--- a/tests/unittests/test_handler/test_handler_snappy.py
+++ b/tests/unittests/test_handler/test_handler_snappy.py
@@ -1,6 +1,7 @@
from cloudinit.config.cc_snappy import (
makeop, get_package_ops, render_snap_op)
from cloudinit import util
+
from .. import helpers as t_help
import os
diff --git a/tests/unittests/test_handler/test_handler_timezone.py b/tests/unittests/test_handler/test_handler_timezone.py
index e3df8759..b7e6b03d 100644
--- a/tests/unittests/test_handler/test_handler_timezone.py
+++ b/tests/unittests/test_handler/test_handler_timezone.py
@@ -28,12 +28,10 @@ from cloudinit.sources import DataSourceNoCloud
from .. import helpers as t_help
from configobj import ConfigObj
-
-from six import BytesIO
-
+import logging
import shutil
+from six import BytesIO
import tempfile
-import logging
LOG = logging.getLogger(__name__)
@@ -72,7 +70,7 @@ class TestTimezone(t_help.FilesystemMockingTestCase):
contents = util.load_file('/etc/sysconfig/clock', decode=False)
n_cfg = ConfigObj(BytesIO(contents))
- self.assertEquals({'TIMEZONE': cfg['timezone']}, dict(n_cfg))
+ self.assertEqual({'TIMEZONE': cfg['timezone']}, dict(n_cfg))
contents = util.load_file('/etc/localtime')
- self.assertEquals(dummy_contents, contents.strip())
+ self.assertEqual(dummy_contents, contents.strip())
diff --git a/tests/unittests/test_handler/test_handler_write_files.py b/tests/unittests/test_handler/test_handler_write_files.py
index f1c7f7b4..466e45f8 100644
--- a/tests/unittests/test_handler/test_handler_write_files.py
+++ b/tests/unittests/test_handler/test_handler_write_files.py
@@ -1,6 +1,6 @@
-from cloudinit import util
-from cloudinit import log as logging
from cloudinit.config.cc_write_files import write_files
+from cloudinit import log as logging
+from cloudinit import util
from ..helpers import FilesystemMockingTestCase
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 3a8aa7c1..28b060f8 100644
--- a/tests/unittests/test_handler/test_handler_yum_add_repo.py
+++ b/tests/unittests/test_handler/test_handler_yum_add_repo.py
@@ -1,16 +1,13 @@
-from cloudinit import util
-
from cloudinit.config import cc_yum_add_repo
+from cloudinit import util
from .. import helpers
-import shutil
-import tempfile
+import configobj
import logging
-
+import shutil
from six import BytesIO
-
-import configobj
+import tempfile
LOG = logging.getLogger(__name__)
@@ -68,4 +65,4 @@ class TestConfig(helpers.FilesystemMockingTestCase):
'gpgcheck': '1',
}
}
- self.assertEquals(expected, dict(contents))
+ self.assertEqual(expected, dict(contents))