diff options
author | Christian Ehrhardt <christian.ehrhardt@canonical.com> | 2016-05-11 11:03:51 +0200 |
---|---|---|
committer | Christian Ehrhardt <christian.ehrhardt@canonical.com> | 2016-05-11 11:03:51 +0200 |
commit | 0e299c89e10a6ccb583588ff31ac783421e57501 (patch) | |
tree | 9204c6f6beb52b33c354027e0ec643ee03d00b23 | |
parent | fef11c6a98ea74774aa84b3b14007b246a1c615e (diff) | |
download | vyos-cloud-init-0e299c89e10a6ccb583588ff31ac783421e57501.tar.gz vyos-cloud-init-0e299c89e10a6ccb583588ff31ac783421e57501.zip |
convert test_apt_source_ppa to use a mocked util.subp
-rw-r--r-- | tests/unittests/test_handler/test_handler_apt_source.py | 16 |
1 files changed, 4 insertions, 12 deletions
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 |