You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by an...@apache.org on 2017/04/13 09:33:29 UTC

[23/46] libcloud git commit: fix azure blobs and skip failed backblaze test

fix azure blobs and skip failed backblaze test


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/80d7cb0d
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/80d7cb0d
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/80d7cb0d

Branch: refs/heads/trunk
Commit: 80d7cb0d4302b2b628953b6b1a7b1da89ae01897
Parents: 4e3be64
Author: Anthony Shaw <an...@apache.org>
Authored: Wed Apr 12 11:27:35 2017 +1000
Committer: Anthony Shaw <an...@apache.org>
Committed: Wed Apr 12 11:27:35 2017 +1000

----------------------------------------------------------------------
 libcloud/http.py                           | 10 ++++++----
 libcloud/test/storage/test_azure_blobs.py  |  5 +++--
 libcloud/test/storage/test_backblaze_b2.py |  1 -
 3 files changed, 9 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/80d7cb0d/libcloud/http.py
----------------------------------------------------------------------
diff --git a/libcloud/http.py b/libcloud/http.py
index d743b4d..8f41124 100644
--- a/libcloud/http.py
+++ b/libcloud/http.py
@@ -202,8 +202,9 @@ class LibcloudConnection(LibcloudBaseConnection):
                 stream=False):
         url = urlparse.urljoin(self.host, url)
         # all headers should be strings
-        if 'Content-Length' in headers and isinstance(headers['Content-Length'], int):
-            headers['Content-Length'] = str(headers['Content-Length'])
+        for header, value in headers.items():
+            if isinstance(headers[header], int):
+                headers[header] = str(value)
         self.response = self.session.request(
             method=method.lower(),
             url=url,
@@ -217,8 +218,9 @@ class LibcloudConnection(LibcloudBaseConnection):
     def prepared_request(self, method, url, body=None,
                          headers=None, raw=False, stream=False):
         # all headers should be strings
-        if 'Content-Length' in headers and isinstance(headers['Content-Length'], int):
-            headers['Content-Length'] = str(headers['Content-Length'])
+        for header, value in headers.items():
+            if isinstance(headers[header], int):
+                headers[header] = str(value)
         req = requests.Request(method, ''.join([self.host, url]),
                                data=body, headers=headers)
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/80d7cb0d/libcloud/test/storage/test_azure_blobs.py
----------------------------------------------------------------------
diff --git a/libcloud/test/storage/test_azure_blobs.py b/libcloud/test/storage/test_azure_blobs.py
index d3a86dc..156bae2 100644
--- a/libcloud/test/storage/test_azure_blobs.py
+++ b/libcloud/test/storage/test_azure_blobs.py
@@ -160,7 +160,7 @@ class AzureBlobsMockHttp(MockHttp):
 
         headers['etag'] = '0x8CFB877BB56A6FB'
         headers['last-modified'] = 'Fri, 04 Jan 2013 09:48:06 GMT'
-        headers['content-length'] = 12345
+        headers['content-length'] = '12345'
         headers['content-type'] = 'application/zip'
         headers['x-ms-blob-type'] = 'Block'
         headers['x-ms-lease-status'] = 'unlocked'
@@ -238,7 +238,7 @@ class AzureBlobsMockHttp(MockHttp):
                 headers,
                 httplib.responses[httplib.NOT_FOUND])
 
-    def _foo_bar_container_foo_bar_object(self, method, url, body, headers):
+    def _foo_bar_container_foo_bar_object_DELETE(self, method, url, body, headers):
         # test_delete_object
         return (httplib.ACCEPTED,
                 body,
@@ -915,6 +915,7 @@ class AzureBlobsTests(unittest.TestCase):
             self.fail('Exception was not thrown')
 
     def test_delete_object_success(self):
+        self.mock_response_klass.type = 'DELETE'
         container = Container(name='foo_bar_container', extra={},
                               driver=self.driver)
         obj = Object(name='foo_bar_object', size=1234, hash=None, extra=None,

http://git-wip-us.apache.org/repos/asf/libcloud/blob/80d7cb0d/libcloud/test/storage/test_backblaze_b2.py
----------------------------------------------------------------------
diff --git a/libcloud/test/storage/test_backblaze_b2.py b/libcloud/test/storage/test_backblaze_b2.py
index 0d077e6..8cec528 100644
--- a/libcloud/test/storage/test_backblaze_b2.py
+++ b/libcloud/test/storage/test_backblaze_b2.py
@@ -95,7 +95,6 @@ class BackblazeB2StorageDriverTestCase(unittest.TestCase):
         container = self.driver.list_containers()[0]
         obj = self.driver.list_container_objects(container=container)[0]
         result = self.driver.download_object_as_stream(obj=obj)
-        result = result.body
         self.assertEqual(result, 'ab')
 
     def test_upload_object(self):