summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChristian Ehrhardt <christian.ehrhardt@canonical.com>2016-05-23 10:53:16 +0200
committerChristian Ehrhardt <christian.ehrhardt@canonical.com>2016-05-23 10:53:16 +0200
commit6b7711dbb75cd3fd31a638f3b530e863eb907708 (patch)
treef1866cca25cdb6e76acb51615cac06f33a0bee23 /tests
parentcf37b78e9bada97a7cc223bd824fb0e8cd8c4c7c (diff)
downloadvyos-cloud-init-6b7711dbb75cd3fd31a638f3b530e863eb907708.tar.gz
vyos-cloud-init-6b7711dbb75cd3fd31a638f3b530e863eb907708.zip
extend test_apt_source_keyid by no filename case
Diffstat (limited to 'tests')
-rw-r--r--tests/unittests/test_handler/test_handler_apt_source.py41
1 files changed, 31 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 050ee78f..c4ba6d00 100644
--- a/tests/unittests/test_handler/test_handler_apt_source.py
+++ b/tests/unittests/test_handler/test_handler_apt_source.py
@@ -148,17 +148,11 @@ class TestAptSourceConfig(TestCase):
with mock.patch.object(os.path, 'join', side_effect=self.myjoin):
self.apt_source_replacement(filename, cfg)
- def test_apt_source_keyid(self):
- """ test_apt_source_keyid
+ def apt_source_keyid(self, filename, cfg):
+ """ apt_source_keyid
Test specification of a source + keyid
"""
params = self._get_default_params()
- cfg = {'source': ('deb '
- 'http://ppa.launchpad.net/'
- 'smoser/cloud-init-test/ubuntu'
- ' xenial main'),
- 'keyid': "03683F77",
- 'filename': self.aptlistfile}
with mock.patch.object(util, 'subp',
return_value=('fakekey 1234', '')) as mockobj:
@@ -166,9 +160,9 @@ class TestAptSourceConfig(TestCase):
mockobj.assert_called_with(('apt-key', 'add', '-'), 'fakekey 1234')
- 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/'
@@ -176,6 +170,33 @@ class TestAptSourceConfig(TestCase):
"xenial", "main"),
contents, flags=re.IGNORECASE))
+ def test_apt_source_keyid(self):
+ """ test_apt_source_keyid
+ Test specification of a source + keyid with filename being set
+ """
+ cfg = {'source': ('deb '
+ 'http://ppa.launchpad.net/'
+ 'smoser/cloud-init-test/ubuntu'
+ ' xenial main'),
+ 'keyid': "03683F77",
+ 'filename': self.aptlistfile}
+ self.apt_source_keyid(self.aptlistfile, cfg)
+
+ def test_apt_source_keyid_nofn(self):
+ """ test_apt_source_keyid
+ Test specification of a source + keyid without filename being set
+ """
+ cfg = {'source': ('deb '
+ 'http://ppa.launchpad.net/'
+ 'smoser/cloud-init-test/ubuntu'
+ ' xenial main'),
+ 'keyid': "03683F77"}
+ # mock into writable tmp dir and check path/content there
+ filename = os.path.join(self.tmp, "etc/apt/sources.list.d/",
+ "cloud_config_sources.list")
+ with mock.patch.object(os.path, 'join', side_effect=self.myjoin):
+ self.apt_source_keyid(filename, cfg)
+
def test_apt_source_key(self):
""" test_apt_source_key
Test specification of a source + key