summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChristian Ehrhardt <christian.ehrhardt@canonical.com>2016-05-23 09:24:44 +0200
committerChristian Ehrhardt <christian.ehrhardt@canonical.com>2016-05-23 09:24:44 +0200
commit29065e4a52a747b4f4cf30092ddcc3744e6aa350 (patch)
tree81a85a5e6a8aa61c14cd0cce2053730ebd5a9f1c /tests
parent8575c4f7045c7074370bba73198ea36571224ece (diff)
downloadvyos-cloud-init-29065e4a52a747b4f4cf30092ddcc3744e6aa350.tar.gz
vyos-cloud-init-29065e4a52a747b4f4cf30092ddcc3744e6aa350.zip
test_apt_source_basic_nofn check for non-specified filename
Cloud-inint uses a default fallback, we want to ensure no code change modfies this behaviour.
Diffstat (limited to 'tests')
-rw-r--r--tests/unittests/test_handler/test_handler_apt_source.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/unittests/test_handler/test_handler_apt_source.py b/tests/unittests/test_handler/test_handler_apt_source.py
index 1b294431..ce356fc6 100644
--- a/tests/unittests/test_handler/test_handler_apt_source.py
+++ b/tests/unittests/test_handler/test_handler_apt_source.py
@@ -47,6 +47,7 @@ class TestAptSourceConfig(TestCase):
self.tmp = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, self.tmp)
self.aptlistfile = os.path.join(self.tmp, "single-deb.list")
+ self.join = os.path.join
@staticmethod
def _get_default_params():
@@ -86,6 +87,30 @@ class TestAptSourceConfig(TestCase):
'filename': self.aptlistfile}
self.apt_source_basic(self.aptlistfile, cfg)
+ def test_apt_source_basic_nofn(self):
+ """ test_apt_source_basic_nofn
+ Test Fix deb source string, has to overwrite mirror conf in params.
+ Test without a filename provided in config and test for known fallback.
+ """
+ cfg = {'source': ('deb http://archive.ubuntu.com/ubuntu'
+ ' karmic-backports'
+ ' main universe multiverse restricted')}
+ # 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")
+
+ def myjoin(*args, **kwargs):
+ """ myjoin - redir into writable tmpdir"""
+ if (args[0] == "/etc/apt/sources.list.d/"
+ and args[1] == "cloud_config_sources.list"
+ and len(args) == 2):
+ return self.join(self.tmp, args[0].lstrip("/"), args[1])
+ else:
+ return self.join(*args, **kwargs)
+
+ with mock.patch.object(os.path, 'join', side_effect=myjoin):
+ self.apt_source_basic(filename, cfg)
+
def test_apt_source_replacement(self):
""" test_apt_source_replace
Test Autoreplacement of MIRROR and RELEASE in source specs