summaryrefslogtreecommitdiff
path: root/tests/unittests/test_handler/test_handler_ntp.py
diff options
context:
space:
mode:
authorJames Falcon <james.falcon@canonical.com>2021-10-15 19:53:42 -0500
committerGitHub <noreply@github.com>2021-10-15 18:53:42 -0600
commita9501251aadf6d30192f7bd7debeabc9c3e29420 (patch)
tree209b109dd17834b35975c52d2d49a532bdd6ef13 /tests/unittests/test_handler/test_handler_ntp.py
parentb3e31ba228d32c318872fb68edda272f679e1004 (diff)
downloadvyos-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_ntp.py')
-rw-r--r--tests/unittests/test_handler/test_handler_ntp.py29
1 files changed, 12 insertions, 17 deletions
diff --git a/tests/unittests/test_handler/test_handler_ntp.py b/tests/unittests/test_handler/test_handler_ntp.py
index 6b9c8377..5dfa564f 100644
--- a/tests/unittests/test_handler/test_handler_ntp.py
+++ b/tests/unittests/test_handler/test_handler_ntp.py
@@ -1,17 +1,17 @@
# This file is part of cloud-init. See LICENSE file for license information.
+import copy
+import os
+import shutil
+from functools import partial
+from os.path import dirname
+from cloudinit import (helpers, util)
from cloudinit.config import cc_ntp
-from cloudinit.sources import DataSourceNone
-from cloudinit import (distros, helpers, cloud, util)
-
from cloudinit.tests.helpers import (
CiTestCase, FilesystemMockingTestCase, mock, skipUnlessJsonSchema)
+from tests.unittests.util import get_cloud
-import copy
-import os
-from os.path import dirname
-import shutil
NTP_TEMPLATE = """\
## template: jinja
@@ -39,16 +39,11 @@ class TestNtp(FilesystemMockingTestCase):
self.m_snappy.return_value = False
self.add_patch('cloudinit.util.system_info', 'm_sysinfo')
self.m_sysinfo.return_value = {'dist': ('Distro', '99.1', 'Codename')}
-
- def _get_cloud(self, distro, sys_cfg=None):
- self.new_root = self.reRoot(root=self.new_root)
- paths = helpers.Paths({'templates_dir': self.new_root})
- cls = distros.fetch(distro)
- if not sys_cfg:
- sys_cfg = {}
- mydist = cls(distro, sys_cfg, paths)
- myds = DataSourceNone.DataSourceNone(sys_cfg, mydist, paths)
- return cloud.Cloud(myds, paths, sys_cfg, mydist, None)
+ self.new_root = self.reRoot()
+ self._get_cloud = partial(
+ get_cloud,
+ paths=helpers.Paths({'templates_dir': self.new_root})
+ )
def _get_template_path(self, template_name, distro, basepath=None):
# ntp.conf.{distro} -> ntp.conf.debian.tmpl