From 6b1f588d8ac266b54bb5608199b01e203497c30f Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Tue, 2 Apr 2013 18:48:59 +0200 Subject: [PATCH] Make sure container is quoted but not object. - Add tests for it. --- swsync/objects.py | 8 ++++---- tests/test_objects.py | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/swsync/objects.py b/swsync/objects.py index af7a2fe..ef5cae1 100644 --- a/swsync/objects.py +++ b/swsync/objects.py @@ -92,13 +92,13 @@ def delete_object(dest_cnx, def sync_object(orig_storage_url, orig_token, dest_storage_url, dest_token, container_name, object_name_etag): + object_name = object_name_etag[1] + orig_headers, orig_body = get_object(orig_storage_url, orig_token, container_name, - object_name_etag[1], - ) - container_name = container_name - object_name = object_name_etag[1] + object_name) + container_name = quote(container_name) post_headers = orig_headers post_headers['x-auth-token'] = dest_token diff --git a/tests/test_objects.py b/tests/test_objects.py index 0760628..4afc92b 100644 --- a/tests/test_objects.py +++ b/tests/test_objects.py @@ -91,6 +91,23 @@ class TestObject(test_base.TestCase): "token", self.dest_storage_url, "token", "cont1", ("etag", "obj1")) + def test_sync_object_utf8(self): + body = "FOO" + new_connect = fake_http_connect(200, body) + self.stubs.Set(swobjects, 'http_connect_raw', new_connect) + + def put_object(url, name=None, headers=None, contents=None): + # Container is Quoted + self.assertFalse(isinstance(url.split("/")[-1], unicode)) + # name is not quoted + self.assertTrue(name, unicode) + + self.stubs.Set(swobjects.swiftclient, 'put_object', put_object) + + swobjects.sync_object(self.orig_storage_url, + "token", self.dest_storage_url, "token", + "contגלאָז", ("etag", "யாமறிந்த")) + def test_get_object_chunked(self): chunk_size = 32 expected_chunk_time = 3