From cea03ed6bc71d9efe77f296662817d766458e3ac Mon Sep 17 00:00:00 2001 From: Christian Ehrhardt Date: Tue, 7 Jun 2016 10:55:14 +0200 Subject: mock get_primary_arch for TestAptSourceConfigSourceList for CentOS This allows the unittest to pass on CentOS, before it failed as it had no dpkg available. --- .../test_handler/test_handler_apt_configure_sources_list.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'tests/unittests') 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 6e123af7..c3043b14 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 @@ -38,6 +38,8 @@ from cloudinit import util from cloudinit.config import cc_apt_configure from cloudinit.sources import DataSourceNone +from cloudinit.distros.debian import Distro + from .. import helpers as t_help LOG = logging.getLogger(__name__) @@ -87,8 +89,6 @@ def load_tfile_or_url(*args, **kwargs): return util.decode_binary(util.read_file_or_url(*args, **kwargs).contents) -# This feature is apt specific and thereby is disabled in environments without -@t_help.skipIf(not os.path.isfile(BIN_APT), "no apt") class TestAptSourceConfigSourceList(t_help.FilesystemMockingTestCase): """TestAptSourceConfigSourceList Main Class to test sources list rendering @@ -180,8 +180,10 @@ class TestAptSourceConfigSourceList(t_help.FilesystemMockingTestCase): with mock.patch.object(util, 'subp', self.subp): with mock.patch.object(cc_apt_configure, 'get_release', return_value='fakerelease'): - cc_apt_configure.handle("notimportant", cfg, mycloud, - LOG, None) + with mock.patch.object(Distro, 'get_primary_arch', + return_value='amd64'): + cc_apt_configure.handle("notimportant", cfg, mycloud, + LOG, None) mockwrite.assert_called_once_with( '/etc/apt/sources.list', -- cgit v1.2.3