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

[3/7] libcloud git commit: Add test cases for it.

Add test cases for it.

Part of LIBCLOUD-745.


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

Branch: refs/heads/trunk
Commit: cf884251d98f7a67a5b35055caa4108500dbc654
Parents: 28a5590
Author: Tomaz Muraus <to...@tomaz.me>
Authored: Tue Sep 19 17:28:08 2017 +0200
Committer: Tomaz Muraus <to...@tomaz.me>
Committed: Tue Sep 19 21:00:18 2017 +0200

----------------------------------------------------------------------
 libcloud/test/storage/test_azure_blobs.py | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/cf884251/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 eb12c0d..95ab3f1 100644
--- a/libcloud/test/storage/test_azure_blobs.py
+++ b/libcloud/test/storage/test_azure_blobs.py
@@ -17,7 +17,6 @@ from __future__ import with_statement
 
 import os
 import sys
-import unittest
 import tempfile
 from io import BytesIO
 
@@ -25,6 +24,7 @@ from libcloud.utils.py3 import httplib
 from libcloud.utils.py3 import urlparse
 from libcloud.utils.py3 import parse_qs
 from libcloud.utils.py3 import b
+from libcloud.utils.py3 import basestring
 
 from libcloud.common.types import InvalidCredsError
 from libcloud.common.types import LibcloudError
@@ -39,12 +39,13 @@ from libcloud.storage.drivers.azure_blobs import AzureBlobsStorageDriver
 from libcloud.storage.drivers.azure_blobs import AZURE_BLOCK_MAX_SIZE
 from libcloud.storage.drivers.azure_blobs import AZURE_PAGE_CHUNK_SIZE
 
+from libcloud.test import unittest
 from libcloud.test import MockHttp, generate_random_data  # pylint: disable-msg=E0611
 from libcloud.test.file_fixtures import StorageFileFixtures  # pylint: disable-msg=E0611
 from libcloud.test.secrets import STORAGE_AZURE_BLOBS_PARAMS
 
 
-class AzureBlobsMockHttp(MockHttp):
+class AzureBlobsMockHttp(MockHttp, unittest.TestCase):
 
     fixtures = StorageFileFixtures('azure_blobs')
     base_headers = {}
@@ -247,6 +248,8 @@ class AzureBlobsMockHttp(MockHttp):
 
     def _foo_bar_container_foo_test_upload(self, method, url, body, headers):
         # test_upload_object_success
+        self._assert_content_length_header_is_string(headers=headers)
+
         body = ''
         headers = {}
         headers['etag'] = '0x8CFB877BB56A6FB'
@@ -259,6 +262,8 @@ class AzureBlobsMockHttp(MockHttp):
     def _foo_bar_container_foo_test_upload_block(self, method, url,
                                                  body, headers):
         # test_upload_object_success
+        self._assert_content_length_header_is_string(headers=headers)
+
         body = ''
         headers = {}
         headers['etag'] = '0x8CFB877BB56A6FB'
@@ -281,6 +286,8 @@ class AzureBlobsMockHttp(MockHttp):
     def _foo_bar_container_foo_test_upload_blocklist(self, method, url,
                                                      body, headers):
         # test_upload_object_success
+        self._assert_content_length_header_is_string(headers=headers)
+
         body = ''
         headers = {}
         headers['etag'] = '0x8CFB877BB56A6FB'
@@ -294,6 +301,8 @@ class AzureBlobsMockHttp(MockHttp):
     def _foo_bar_container_foo_test_upload_lease(self, method, url,
                                                  body, headers):
         # test_upload_object_success
+        self._assert_content_length_header_is_string(headers=headers)
+
         action = headers['x-ms-lease-action']
         rheaders = {'x-ms-lease-id': 'someleaseid'}
         body = ''
@@ -318,12 +327,14 @@ class AzureBlobsMockHttp(MockHttp):
 
     def _foo_bar_container_foo_test_upload_INVALID_HASH(self, method, url,
                                                         body, headers):
+        # test_upload_object_invalid_hash1
+        self._assert_content_length_header_is_string(headers=headers)
+
         body = ''
         headers = {}
         headers['etag'] = '0x8CFB877BB56A6FB'
         headers['content-md5'] = 'd4fe4c9829f7ca1cc89db7ad670d2bbd'
 
-        # test_upload_object_invalid_hash1
         return (httplib.CREATED,
                 body,
                 headers,
@@ -331,6 +342,8 @@ class AzureBlobsMockHttp(MockHttp):
 
     def _foo_bar_container_foo_bar_object(self, method, url, body, headers):
         # test_upload_object_invalid_file_size
+        self._assert_content_length_header_is_string(headers=headers)
+
         body = generate_random_data(1000)
         return (httplib.OK,
                 body,
@@ -340,12 +353,18 @@ class AzureBlobsMockHttp(MockHttp):
     def _foo_bar_container_foo_bar_object_INVALID_SIZE(self, method, url,
                                                        body, headers):
         # test_upload_object_invalid_file_size
+        self._assert_content_length_header_is_string(headers=headers)
+
         body = ''
         return (httplib.OK,
                 body,
                 headers,
                 httplib.responses[httplib.OK])
 
+    def _assert_content_length_header_is_string(self, headers):
+        if 'Content-Length' in headers:
+            self.assertTrue(isinstance(headers['Content-Length'], basestring))
+
 
 class AzureBlobsTests(unittest.TestCase):
     driver_type = AzureBlobsStorageDriver