summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/unittests/test_data.py17
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))