Merge branch '3785-job-log-collection-owner' closes #3785
[arvados.git] / sdk / python / tests / test_keep_client.py
index 6d4d3cd8b816ea3854151285cd46cdebf60f5e63..ad1d7a9c87cef02bd42812e8168328c902b09538 100644 (file)
@@ -76,6 +76,21 @@ class KeepTestCase(run_test_server.TestCaseWithServers):
             '^d41d8cd98f00b204e9800998ecf8427e\+0',
             ('wrong locator from Keep.put(""): ' + blob_locator))
 
+    def test_unicode_must_be_ascii(self):
+        # If unicode type, must only consist of valid ASCII
+        foo_locator = self.keep_client.put(u'foo')
+        self.assertRegexpMatches(
+            foo_locator,
+            '^acbd18db4cc2f85cedef654fccc4a4d8\+3',
+            'wrong md5 hash from Keep.put("foo"): ' + foo_locator)
+
+        with self.assertRaises(UnicodeEncodeError):
+            # Error if it is not ASCII
+            self.keep_client.put(u'\xe2')
+
+        with self.assertRaises(arvados.errors.ArgumentError):
+            # Must be a string type
+            self.keep_client.put({})
 
 class KeepPermissionTestCase(run_test_server.TestCaseWithServers):
     MAIN_SERVER = {}