summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Ehrhardt <christian.ehrhardt@canonical.com>2016-05-10 14:59:57 +0200
committerChristian Ehrhardt <christian.ehrhardt@canonical.com>2016-05-10 14:59:57 +0200
commitb0494addabfe1d07947427ade99a00d2c7588f12 (patch)
treece38ff938b0fdd880c88e55e69e4bb1a1ed114ff
parenteeabe2ed7480dc653c9d65d218738a8ed5a21579 (diff)
downloadvyos-cloud-init-b0494addabfe1d07947427ade99a00d2c7588f12.tar.gz
vyos-cloud-init-b0494addabfe1d07947427ade99a00d2c7588f12.zip
split into basic and replacement test
-rw-r--r--tests/unittests/test_handler/test_handler_apt_source.py37
1 files changed, 28 insertions, 9 deletions
diff --git a/tests/unittests/test_handler/test_handler_apt_source.py b/tests/unittests/test_handler/test_handler_apt_source.py
index b45fc1d1..a9647156 100644
--- a/tests/unittests/test_handler/test_handler_apt_source.py
+++ b/tests/unittests/test_handler/test_handler_apt_source.py
@@ -62,14 +62,31 @@ class TestAptSourceConfig(TestCase):
params['MIRROR'] = "http://archive.ubuntu.com/ubuntu"
return params
- @staticmethod
- def _search_apt_source(contents, params, pre, post):
- return re.search(r"%s %s %s %s\n" %
- (pre, params['MIRROR'], params['RELEASE'], post),
- contents, flags=re.IGNORECASE)
- def test_apt_source_release(self):
- """ test_apt_source_release
+ def test_apt_source_basic(self):
+ """ test_apt_source_basic
+ Test Fix deb source string, has to overwrite mirror conf in params
+ """
+ params = self._get_default_params()
+ cfg = {'source': ('deb http://archive.ubuntu.com/ubuntu'
+ ' karmic-backports'
+ ' main universe multiverse restricted'),
+ 'filename': self.aptlistfile}
+
+ cc_apt_configure.add_sources([cfg], params)
+
+ self.assertTrue(os.path.isfile(self.aptlistfile))
+
+ contents = load_tfile_or_url(self.aptlistfile)
+ self.assertTrue(re.search(r"%s %s %s %s\n" %
+ ("deb", "http://archive.ubuntu.com/ubuntu",
+ "karmic-backports",
+ "main universe multiverse restricted"),
+ contents, flags=re.IGNORECASE))
+
+
+ def test_apt_source_replacement(self):
+ """ test_apt_source_replace
Test Autoreplacement of MIRROR and RELEASE in source specs
"""
params = self._get_default_params()
@@ -81,7 +98,9 @@ class TestAptSourceConfig(TestCase):
self.assertTrue(os.path.isfile(self.aptlistfile))
contents = load_tfile_or_url(self.aptlistfile)
- self.assertTrue(self._search_apt_source(contents, params,
- "deb", "multiverse"))
+ self.assertTrue(re.search(r"%s %s %s %s\n" %
+ ("deb", params['MIRROR'], params['RELEASE'],
+ "multiverse"),
+ contents, flags=re.IGNORECASE))
# vi: ts=4 expandtab