summaryrefslogtreecommitdiff
path: root/tests/unittests
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unittests')
-rw-r--r--tests/unittests/test_handler/test_handler_apt_source.py38
1 files changed, 28 insertions, 10 deletions
diff --git a/tests/unittests/test_handler/test_handler_apt_source.py b/tests/unittests/test_handler/test_handler_apt_source.py
index 79c33b4e..516dc694 100644
--- a/tests/unittests/test_handler/test_handler_apt_source.py
+++ b/tests/unittests/test_handler/test_handler_apt_source.py
@@ -190,26 +190,20 @@ class TestAptSourceConfig(TestCase):
with mock.patch.object(os.path, 'join', side_effect=self.myjoin):
self.apt_source_keyid(self.fallbackfn, cfg)
- def test_apt_source_key(self):
- """ test_apt_source_key
+ def apt_source_key(self, filename, cfg):
+ """ apt_source_key
Test specification of a source + key
"""
params = self._get_default_params()
- cfg = {'source': ('deb '
- 'http://ppa.launchpad.net/'
- 'smoser/cloud-init-test/ubuntu'
- ' xenial main'),
- 'key': "fakekey 4321",
- 'filename': self.aptlistfile}
with mock.patch.object(util, 'subp') as mockobj:
cc_apt_configure.add_sources([cfg], params)
mockobj.assert_called_with(('apt-key', 'add', '-'), 'fakekey 4321')
- self.assertTrue(os.path.isfile(self.aptlistfile))
+ self.assertTrue(os.path.isfile(filename))
- contents = load_tfile_or_url(self.aptlistfile)
+ contents = load_tfile_or_url(filename)
self.assertTrue(re.search(r"%s %s %s %s\n" %
("deb",
('http://ppa.launchpad.net/smoser/'
@@ -217,6 +211,30 @@ class TestAptSourceConfig(TestCase):
"xenial", "main"),
contents, flags=re.IGNORECASE))
+ def test_apt_source_key(self):
+ """ test_apt_source_key
+ Test specification of a source + key with filename being set
+ """
+ cfg = {'source': ('deb '
+ 'http://ppa.launchpad.net/'
+ 'smoser/cloud-init-test/ubuntu'
+ ' xenial main'),
+ 'key': "fakekey 4321",
+ 'filename': self.aptlistfile}
+ self.apt_source_key(self.aptlistfile, cfg)
+
+ def test_apt_source_key_nofn(self):
+ """ test_apt_source_key
+ Test specification of a source + key without filename being set
+ """
+ cfg = {'source': ('deb '
+ 'http://ppa.launchpad.net/'
+ 'smoser/cloud-init-test/ubuntu'
+ ' xenial main'),
+ 'key': "fakekey 4321"}
+ with mock.patch.object(os.path, 'join', side_effect=self.myjoin):
+ self.apt_source_key(self.fallbackfn, cfg)
+
def test_apt_source_keyonly(self):
""" test_apt_source_keyonly
Test specification key without source