From 83f2351bba273273d04759ebacd2a25df9045090 Mon Sep 17 00:00:00 2001 From: Christian Ehrhardt Date: Thu, 12 May 2016 13:28:36 +0200 Subject: test debian and ubuntu source.list templating --- .../test_handler_apt_configure_sources_list.py | 32 ++++++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/tests/unittests/test_handler/test_handler_apt_configure_sources_list.py b/tests/unittests/test_handler/test_handler_apt_configure_sources_list.py index 46edb628..aff272a3 100644 --- a/tests/unittests/test_handler/test_handler_apt_configure_sources_list.py +++ b/tests/unittests/test_handler/test_handler_apt_configure_sources_list.py @@ -58,15 +58,15 @@ class TestAptSourceConfigSourceList(t_help.FilesystemMockingTestCase): # TODO Later - custom template filename # TODO Later - custom template raw - def test_apt_source_list_ubuntu(self): - """ test_apt_source_list - Test rendering of a source.list from template for ubuntu + def apt_source_list(self, distro, mirror): + """ apt_source_list + Test rendering of a source.list from template for a given distro """ self.patchOS(self.new_root) self.patchUtils(self.new_root) - cfg = {'apt_mirror': 'http://archive.ubuntu.com/ubuntu/'} - mycloud = self._get_cloud('ubuntu') + cfg = {'apt_mirror': mirror} + mycloud = self._get_cloud(distro) with mock.patch.object(templater, 'render_to_file') as mocktmpl: with mock.patch.object(os.path, 'isfile', @@ -75,15 +75,29 @@ class TestAptSourceConfigSourceList(t_help.FilesystemMockingTestCase): LOG, None) mockisfile.assert_any_call(('/etc/cloud/templates/' - 'sources.list.ubuntu.tmpl')) + 'sources.list.%s.tmpl' % distro)) mocktmpl.assert_called_once_with(('/etc/cloud/templates/' - 'sources.list.ubuntu.tmpl'), + 'sources.list.%s.tmpl' % distro), '/etc/apt/sources.list', {'codename': '', 'primary': - 'http://archive.ubuntu.com/ubuntu/', + mirror, 'mirror': - 'http://archive.ubuntu.com/ubuntu/'}) + mirror}) + + + def test_apt_source_list_ubuntu(self): + """ test_apt_source_list_ubuntu + Test rendering of a source.list from template for ubuntu + """ + self.apt_source_list('ubuntu', 'http://archive.ubuntu.com/ubuntu/') + + + def test_apt_source_list_debian(self): + """ test_apt_source_list_debian + Test rendering of a source.list from template for debian + """ + self.apt_source_list('debian', 'ftp.us.debian.org') # vi: ts=4 expandtab -- cgit v1.2.3