summaryrefslogtreecommitdiff
path: root/tests/unittests/test_pathprefix2dict.py
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2014-01-29 14:32:51 -0500
committerScott Moser <smoser@ubuntu.com>2014-01-29 14:32:51 -0500
commit3cfe9b3d8958b1a4e450d5ff31d805c424945027 (patch)
treeb05977c13f4d8dbdb111b7392e2a5689ad381b84 /tests/unittests/test_pathprefix2dict.py
parent06c80d8b0dcb8cf1013885fc745bf48d57b39ce4 (diff)
parent29b56e5ad6a5ec0eedbedcc598f633b1f5302a8a (diff)
downloadvyos-cloud-init-3cfe9b3d8958b1a4e450d5ff31d805c424945027.tar.gz
vyos-cloud-init-3cfe9b3d8958b1a4e450d5ff31d805c424945027.zip
DataSourceNoCloud: support reading vendor-data
Here we add the ability to read vendor-data from a file named vendor-data at the same location as the user-data and meta-data files. At the moment, vendor-data is not read at all from 'seedfrom'.
Diffstat (limited to 'tests/unittests/test_pathprefix2dict.py')
-rw-r--r--tests/unittests/test_pathprefix2dict.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/unittests/test_pathprefix2dict.py b/tests/unittests/test_pathprefix2dict.py
new file mode 100644
index 00000000..c68c263c
--- /dev/null
+++ b/tests/unittests/test_pathprefix2dict.py
@@ -0,0 +1,40 @@
+from cloudinit import util
+
+from mocker import MockerTestCase
+from tests.unittests.helpers import populate_dir
+
+
+class TestPathPrefix2Dict(MockerTestCase):
+
+ def setUp(self):
+ self.tmp = self.makeDir()
+
+ def test_required_only(self):
+ dirdata = {'f1': 'f1content', 'f2': 'f2content'}
+ populate_dir(self.tmp, dirdata)
+
+ ret = util.pathprefix2dict(self.tmp, required=['f1', 'f2'])
+ self.assertEqual(dirdata, ret)
+
+ def test_required_missing(self):
+ dirdata = {'f1': 'f1content'}
+ populate_dir(self.tmp, dirdata)
+ kwargs = {'required': ['f1', 'f2']}
+ self.assertRaises(ValueError, util.pathprefix2dict, self.tmp, **kwargs)
+
+ def test_no_required_and_optional(self):
+ dirdata = {'f1': 'f1c', 'f2': 'f2c'}
+ populate_dir(self.tmp, dirdata)
+
+ ret = util.pathprefix2dict(self.tmp, required=None,
+ optional=['f1', 'f2'])
+ self.assertEqual(dirdata, ret)
+
+ def test_required_and_optional(self):
+ dirdata = {'f1': 'f1c', 'f2': 'f2c'}
+ populate_dir(self.tmp, dirdata)
+
+ ret = util.pathprefix2dict(self.tmp, required=['f1'], optional=['f2'])
+ self.assertEqual(dirdata, ret)
+
+# vi: ts=4 expandtab