diff options
author | Christian Ehrhardt <christian.ehrhardt@canonical.com> | 2016-05-23 10:59:45 +0200 |
---|---|---|
committer | Christian Ehrhardt <christian.ehrhardt@canonical.com> | 2016-05-23 10:59:45 +0200 |
commit | 1926eb2476f9e1fda3356c7828479231dccc309b (patch) | |
tree | 80014816863a0eab89d8cd6d9eda5b32c6745e2c /tests/unittests | |
parent | 0b2cbda06a5622bc2b6dcc4f2d4190824528f1f6 (diff) | |
download | vyos-cloud-init-1926eb2476f9e1fda3356c7828479231dccc309b.tar.gz vyos-cloud-init-1926eb2476f9e1fda3356c7828479231dccc309b.zip |
extend test_apt_source_key by nofn case
Diffstat (limited to 'tests/unittests')
-rw-r--r-- | tests/unittests/test_handler/test_handler_apt_source.py | 38 |
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 |