summaryrefslogtreecommitdiff
path: root/tests/unittests
diff options
context:
space:
mode:
authorRobert Schweikert <rjschwei@suse.com>2016-09-15 12:05:15 -0400
committerScott Moser <smoser@brickies.net>2016-09-21 22:07:04 -0400
commit0439d8a17d181a2546f2f7cb2d71a04bbb13b186 (patch)
tree9014243afbc5a90733e63e64343f4e118aaa227a /tests/unittests
parent1b71b474c0fc06e67aab8676268fd83d99091910 (diff)
downloadvyos-cloud-init-0439d8a17d181a2546f2f7cb2d71a04bbb13b186.tar.gz
vyos-cloud-init-0439d8a17d181a2546f2f7cb2d71a04bbb13b186.zip
Decode unicode types in decode_binary
The test in decode_binary for six.text_type was incorrect as that includes unicode type in Python 2 which should actually be decoded. When the type is string_types we now properly check only for basestring and str in Python 2 and Python 3 respectively and return the given blob without making an attempt to decode.
Diffstat (limited to 'tests/unittests')
-rw-r--r--tests/unittests/test_util.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/unittests/test_util.py b/tests/unittests/test_util.py
index 30f603cb..fc6b9d40 100644
--- a/tests/unittests/test_util.py
+++ b/tests/unittests/test_util.py
@@ -603,4 +603,12 @@ class TestSubp(helpers.TestCase):
self.assertEqual("/target/my/path/",
util.target_path("/target/", "///my/path/"))
+
+class TestEncode(helpers.TestCase):
+ """Test the encoding functions"""
+ def test_decode_binary_plain_text_with_hex(self):
+ blob = 'BOOTABLE_FLAG=\x80init=/bin/systemd'
+ text = util.decode_binary(blob)
+ self.assertEqual(text, blob)
+
# vi: ts=4 expandtab