summaryrefslogtreecommitdiff
path: root/tests/unittests/test_handler
diff options
context:
space:
mode:
authorRyan Harper <ryan.harper@canonical.com>2019-07-16 20:57:32 +0000
committerServer Team CI Bot <josh.powers+server-team-bot@canonical.com>2019-07-16 20:57:32 +0000
commit14048171f8e5273b1b82c6d2ed5675a7d1a6eeb6 (patch)
tree34fd0865650c5face2e2db451df57704b2abc817 /tests/unittests/test_handler
parenta785462959e8746cc16609a159fee33dedd713b1 (diff)
downloadvyos-cloud-init-14048171f8e5273b1b82c6d2ed5675a7d1a6eeb6.tar.gz
vyos-cloud-init-14048171f8e5273b1b82c6d2ed5675a7d1a6eeb6.zip
templates/ntp.conf.debian.tmpl: fix missing newline for pools
The debian ntp.conf template did not contain a newline for the comment used to mark the rendered ntp pools configured. This resulted in an invalid line: '# poolspool 0.int.pool.ntp.org iburst' rather than: '# pools  pool 0.int.pool.ntp.org iburst' This patch fixes the template and updates the unittest to verify that the rendered templates puts servers and pools at the beginning of a line. LP: #1836598
Diffstat (limited to 'tests/unittests/test_handler')
-rw-r--r--tests/unittests/test_handler/test_handler_ntp.py25
1 files changed, 15 insertions, 10 deletions
diff --git a/tests/unittests/test_handler/test_handler_ntp.py b/tests/unittests/test_handler/test_handler_ntp.py
index 0f22e579..463d892a 100644
--- a/tests/unittests/test_handler/test_handler_ntp.py
+++ b/tests/unittests/test_handler/test_handler_ntp.py
@@ -268,17 +268,22 @@ class TestNtp(FilesystemMockingTestCase):
template_fn=template_fn)
content = util.load_file(confpath)
if client in ['ntp', 'chrony']:
- expected_servers = '\n'.join([
- 'server {0} iburst'.format(srv) for srv in servers])
+ content_lines = content.splitlines()
+ expected_servers = [
+ 'server {0} iburst'.format(srv) for srv in servers]
print('distro=%s client=%s' % (distro, client))
- self.assertIn(expected_servers, content,
- ('failed to render {0} conf'
- ' for distro:{1}'.format(client, distro)))
- expected_pools = '\n'.join([
- 'pool {0} iburst'.format(pool) for pool in pools])
- self.assertIn(expected_pools, content,
- ('failed to render {0} conf'
- ' for distro:{1}'.format(client, distro)))
+ for sline in expected_servers:
+ self.assertIn(sline, content_lines,
+ ('failed to render {0} conf'
+ ' for distro:{1}'.format(client,
+ distro)))
+ expected_pools = [
+ 'pool {0} iburst'.format(pool) for pool in pools]
+ for pline in expected_pools:
+ self.assertIn(pline, content_lines,
+ ('failed to render {0} conf'
+ ' for distro:{1}'.format(client,
+ distro)))
elif client == 'systemd-timesyncd':
expected_content = (
"# cloud-init generated file\n" +