summaryrefslogtreecommitdiff
path: root/tests/unittests/test_util.py
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2015-05-14 17:06:39 -0400
committerScott Moser <smoser@ubuntu.com>2015-05-14 17:06:39 -0400
commit74023961b70a178039ecf10f68745f6927113978 (patch)
treeab0f02962d1fcb87c5fae3af54ca645baa04bf45 /tests/unittests/test_util.py
parent6d7ac1c317776b7266ffd8ffaa6610ca6918a7d0 (diff)
downloadvyos-cloud-init-74023961b70a178039ecf10f68745f6927113978.tar.gz
vyos-cloud-init-74023961b70a178039ecf10f68745f6927113978.zip
read_seeded: fix reed_seeded after regression
read_seeded was assuming a Response object back from load_tfile_or_url but load_tfile_or_url was returning string. since the only other user of this was a test, move load_tfile_or_url to a test, and just do the right thing in read_seeded. LP: #1455233
Diffstat (limited to 'tests/unittests/test_util.py')
-rw-r--r--tests/unittests/test_util.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/unittests/test_util.py b/tests/unittests/test_util.py
index 1619b5d2..95990165 100644
--- a/tests/unittests/test_util.py
+++ b/tests/unittests/test_util.py
@@ -459,4 +459,21 @@ class TestMessageFromString(helpers.TestCase):
roundtripped = util.message_from_string(u'\n').as_string()
self.assertNotIn('\x00', roundtripped)
+
+class TestReadSeeded(helpers.TestCase):
+ def setUp(self):
+ super(TestReadSeeded, self).setUp()
+ self.tmp = tempfile.mkdtemp()
+ self.addCleanup(shutil.rmtree, self.tmp)
+
+ def test_unicode_not_messed_up(self):
+ ud = b"userdatablob"
+ helpers.populate_dir(
+ self.tmp, {'meta-data': "key1: val1", 'user-data': ud})
+ sdir = self.tmp + os.path.sep
+ (found_md, found_ud) = util.read_seeded(sdir)
+
+ self.assertEqual(found_md, {'key1': 'val1'})
+ self.assertEqual(found_ud, ud)
+
# vi: ts=4 expandtab