diff options
author | Scott Moser <smoser@ubuntu.com> | 2016-07-13 22:14:13 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2016-07-13 22:14:13 -0400 |
commit | e1d68c11c44ab11acf3f7b234a1db45d85ae19de (patch) | |
tree | 9b7c46af243ebf14590eb711f05f243d8ba56cf8 /tests | |
parent | 2a8dc75a5b8ab42ca805f2ec6b97dc7a074e82f3 (diff) | |
parent | b3193a4b5204d12825d8317bf0f8c3577c1d8153 (diff) | |
download | vyos-cloud-init-e1d68c11c44ab11acf3f7b234a1db45d85ae19de.tar.gz vyos-cloud-init-e1d68c11c44ab11acf3f7b234a1db45d85ae19de.zip |
merge with trunk
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unittests/test_data.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/unittests/test_data.py b/tests/unittests/test_data.py index 1923e2af..13db8a4c 100644 --- a/tests/unittests/test_data.py +++ b/tests/unittests/test_data.py @@ -557,3 +557,20 @@ class TestUDProcess(helpers.ResourceUsingTestCase): ud_proc = ud.UserDataProcessor(self.getCloudPaths()) message = ud_proc.process(msg) self.assertTrue(count_messages(message) == 1) + + +class TestConvertString(helpers.TestCase): + def test_handles_binary_non_utf8_decodable(self): + blob = b'\x32\x99' + msg = ud.convert_string(blob) + self.assertEqual(blob, msg.get_payload(decode=True)) + + def test_handles_binary_utf8_decodable(self): + blob = b'\x32\x32' + msg = ud.convert_string(blob) + self.assertEqual(blob, msg.get_payload(decode=True)) + + def test_handle_headers(self): + text = "hi mom" + msg = ud.convert_string(text) + self.assertEqual(text, msg.get_payload(decode=False)) |