summaryrefslogtreecommitdiff
path: root/tests/unittests/test_handler/test_handler_lxd.py
diff options
context:
space:
mode:
authorScott Moser <smoser@brickies.net>2017-10-20 16:05:04 -0600
committerChad Smith <chad.smith@canonical.com>2017-10-20 16:06:58 -0600
commitc06eea972eb4b7bfa68f4f542f2fb67ea1d455ac (patch)
tree258b4301f3cebc23d8c2031cf9209e29b51de358 /tests/unittests/test_handler/test_handler_lxd.py
parenta51968d50e7cdecabaf255c26386fd82f6640cc3 (diff)
downloadvyos-cloud-init-c06eea972eb4b7bfa68f4f542f2fb67ea1d455ac.tar.gz
vyos-cloud-init-c06eea972eb4b7bfa68f4f542f2fb67ea1d455ac.zip
citest: fix remaining warnings raised by integration tests.
There was fallout in a full integration test run from my adding of test_no_warnings_in_log which asserted that there could not be a WARNING found in the /var/log/cloud-init.log This fixes 2 of the cases: * TestCommandOutputSimple had a valid WARNING written, so adjust its test case to allow for that. * TestLxdDir had a valid config in the test but the module would log a WARNING, so fix the module. Also updates lxd unit tests to look for WARN themselves.
Diffstat (limited to 'tests/unittests/test_handler/test_handler_lxd.py')
-rw-r--r--tests/unittests/test_handler/test_handler_lxd.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/tests/unittests/test_handler/test_handler_lxd.py b/tests/unittests/test_handler/test_handler_lxd.py
index f132a778..e0d9ab6c 100644
--- a/tests/unittests/test_handler/test_handler_lxd.py
+++ b/tests/unittests/test_handler/test_handler_lxd.py
@@ -5,17 +5,16 @@ from cloudinit.sources import DataSourceNoCloud
from cloudinit import (distros, helpers, cloud)
from cloudinit.tests import helpers as t_help
-import logging
-
try:
from unittest import mock
except ImportError:
import mock
-LOG = logging.getLogger(__name__)
+class TestLxd(t_help.CiTestCase):
+
+ with_logs = True
-class TestLxd(t_help.TestCase):
lxd_cfg = {
'lxd': {
'init': {
@@ -41,7 +40,7 @@ class TestLxd(t_help.TestCase):
def test_lxd_init(self, mock_util):
cc = self._get_cloud('ubuntu')
mock_util.which.return_value = True
- cc_lxd.handle('cc_lxd', self.lxd_cfg, cc, LOG, [])
+ cc_lxd.handle('cc_lxd', self.lxd_cfg, cc, self.logger, [])
self.assertTrue(mock_util.which.called)
init_call = mock_util.subp.call_args_list[0][0][0]
self.assertEqual(init_call,
@@ -55,7 +54,8 @@ class TestLxd(t_help.TestCase):
cc = self._get_cloud('ubuntu')
cc.distro = mock.MagicMock()
mock_util.which.return_value = None
- cc_lxd.handle('cc_lxd', self.lxd_cfg, cc, LOG, [])
+ cc_lxd.handle('cc_lxd', self.lxd_cfg, cc, self.logger, [])
+ self.assertNotIn('WARN', self.logs.getvalue())
self.assertTrue(cc.distro.install_packages.called)
install_pkg = cc.distro.install_packages.call_args_list[0][0][0]
self.assertEqual(sorted(install_pkg), ['lxd', 'zfs'])
@@ -64,7 +64,7 @@ class TestLxd(t_help.TestCase):
def test_no_init_does_nothing(self, mock_util):
cc = self._get_cloud('ubuntu')
cc.distro = mock.MagicMock()
- cc_lxd.handle('cc_lxd', {'lxd': {}}, cc, LOG, [])
+ cc_lxd.handle('cc_lxd', {'lxd': {}}, cc, self.logger, [])
self.assertFalse(cc.distro.install_packages.called)
self.assertFalse(mock_util.subp.called)
@@ -72,7 +72,7 @@ class TestLxd(t_help.TestCase):
def test_no_lxd_does_nothing(self, mock_util):
cc = self._get_cloud('ubuntu')
cc.distro = mock.MagicMock()
- cc_lxd.handle('cc_lxd', {'package_update': True}, cc, LOG, [])
+ cc_lxd.handle('cc_lxd', {'package_update': True}, cc, self.logger, [])
self.assertFalse(cc.distro.install_packages.called)
self.assertFalse(mock_util.subp.called)