From 0e299c89e10a6ccb583588ff31ac783421e57501 Mon Sep 17 00:00:00 2001 From: Christian Ehrhardt Date: Wed, 11 May 2016 11:03:51 +0200 Subject: convert test_apt_source_ppa to use a mocked util.subp --- tests/unittests/test_handler/test_handler_apt_source.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'tests/unittests') diff --git a/tests/unittests/test_handler/test_handler_apt_source.py b/tests/unittests/test_handler/test_handler_apt_source.py index 601504bd..e73a72c6 100644 --- a/tests/unittests/test_handler/test_handler_apt_source.py +++ b/tests/unittests/test_handler/test_handler_apt_source.py @@ -148,21 +148,13 @@ class TestAptSourceConfig(TestCase): # default matcher needed for ppa matcher = re.compile(r'^[\w-]+:\w').search - cc_apt_configure.add_sources([cfg], params, aa_repo_match=matcher) + with mock.patch.object(util, 'subp') as mockobj: + cc_apt_configure.add_sources([cfg], params, aa_repo_match=matcher) + mockobj.assert_called_once_with(['add-apt-repository', + 'ppa:smoser/cloud-init-test']) # adding ppa should ignore filename (uses add-apt-repository) self.assertFalse(os.path.isfile(self.aptlistfile)) - expected_sources_fn=('/etc/apt/sources.list.d/' - 'smoser-ubuntu-cloud-init-test-%s.list' - % params['RELEASE']) - print("filename: %s" % expected_sources_fn) - self.assertTrue(os.path.isfile(expected_sources_fn)) - - # file gets not created, might be permission or env detail - contents = load_tfile_or_url(expected_sources_fn) - print(contents) - # intentional debug exit - self.assertRaises(ValueError) # vi: ts=4 expandtab -- cgit v1.2.3