diff options
author | James Falcon <james.falcon@canonical.com> | 2021-10-15 19:53:42 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-15 18:53:42 -0600 |
commit | a9501251aadf6d30192f7bd7debeabc9c3e29420 (patch) | |
tree | 209b109dd17834b35975c52d2d49a532bdd6ef13 /tests/unittests/test_handler/test_handler_debug.py | |
parent | b3e31ba228d32c318872fb68edda272f679e1004 (diff) | |
download | vyos-cloud-init-a9501251aadf6d30192f7bd7debeabc9c3e29420.tar.gz vyos-cloud-init-a9501251aadf6d30192f7bd7debeabc9c3e29420.zip |
testing: add get_cloud function (SC-461) (#1038)
Also added supporting distro/datasource classes and updated tests
that have a `get_cloud` call.
Diffstat (limited to 'tests/unittests/test_handler/test_handler_debug.py')
-rw-r--r-- | tests/unittests/test_handler/test_handler_debug.py | 29 |
1 files changed, 7 insertions, 22 deletions
diff --git a/tests/unittests/test_handler/test_handler_debug.py b/tests/unittests/test_handler/test_handler_debug.py index 7d43e020..41e9d9bd 100644 --- a/tests/unittests/test_handler/test_handler_debug.py +++ b/tests/unittests/test_handler/test_handler_debug.py @@ -1,21 +1,15 @@ # Copyright (C) 2014 Yahoo! Inc. # # This file is part of cloud-init. See LICENSE file for license information. +import logging +import shutil +import tempfile -from cloudinit.config import cc_debug - -from cloudinit import cloud -from cloudinit import distros -from cloudinit import helpers from cloudinit import util - -from cloudinit.sources import DataSourceNone - +from cloudinit.config import cc_debug from cloudinit.tests.helpers import (FilesystemMockingTestCase, mock) -import logging -import shutil -import tempfile +from tests.unittests.util import get_cloud LOG = logging.getLogger(__name__) @@ -26,16 +20,7 @@ class TestDebug(FilesystemMockingTestCase): super(TestDebug, self).setUp() self.new_root = tempfile.mkdtemp() self.addCleanup(shutil.rmtree, self.new_root) - - def _get_cloud(self, distro, metadata=None): self.patchUtils(self.new_root) - paths = helpers.Paths({}) - cls = distros.fetch(distro) - d = cls(distro, {}, paths) - ds = DataSourceNone.DataSourceNone({}, d, paths) - if metadata: - ds.metadata.update(metadata) - return cloud.Cloud(ds, paths, {}, d, None) def test_debug_write(self, m_locale): m_locale.return_value = 'en_US.UTF-8' @@ -48,7 +33,7 @@ class TestDebug(FilesystemMockingTestCase): 'output': '/var/log/cloud-init-debug.log', }, } - cc = self._get_cloud('ubuntu') + cc = get_cloud() cc_debug.handle('cc_debug', cfg, cc, LOG, []) contents = util.load_file('/var/log/cloud-init-debug.log') # Some basic sanity tests... @@ -66,7 +51,7 @@ class TestDebug(FilesystemMockingTestCase): 'output': '/var/log/cloud-init-debug.log', }, } - cc = self._get_cloud('ubuntu') + cc = get_cloud() cc_debug.handle('cc_debug', cfg, cc, LOG, []) self.assertRaises(IOError, util.load_file, '/var/log/cloud-init-debug.log') |