libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anthonys...@apache.org
Subject [21/46] libcloud git commit: fix oss tests
Date Thu, 13 Apr 2017 09:33:27 GMT
fix oss tests


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

Branch: refs/heads/trunk
Commit: 1a3ff04f9d7ea826c0c4c176423d8586ae20f65f
Parents: da0a40e
Author: Anthony Shaw <anthonyshaw@apache.org>
Authored: Wed Apr 12 10:57:38 2017 +1000
Committer: Anthony Shaw <anthonyshaw@apache.org>
Committed: Wed Apr 12 10:57:38 2017 +1000

----------------------------------------------------------------------
 libcloud/test/storage/test_oss.py | 28 +++++++++++-----------------
 1 file changed, 11 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/1a3ff04f/libcloud/test/storage/test_oss.py
----------------------------------------------------------------------
diff --git a/libcloud/test/storage/test_oss.py b/libcloud/test/storage/test_oss.py
index e20c3cb..830fb74 100644
--- a/libcloud/test/storage/test_oss.py
+++ b/libcloud/test/storage/test_oss.py
@@ -47,7 +47,7 @@ from libcloud.storage.drivers.oss import OSSConnection
 from libcloud.storage.drivers.oss import OSSStorageDriver
 from libcloud.storage.drivers.oss import CHUNK_SIZE
 from libcloud.storage.drivers.dummy import DummyIterator
-from libcloud.test import MockHttp, generate_random_data  # pylint: disable-msg=E0611
+from libcloud.test import MockHttp, generate_random_data, make_response  # pylint: disable-msg=E0611
 from libcloud.test.file_fixtures import StorageFileFixtures  # pylint: disable-msg=E0611
 from libcloud.test.secrets import STORAGE_OSS_PARAMS
 
@@ -84,7 +84,7 @@ class ObjectTestCase(unittest.TestCase):
         self.assertTrue(obj.__repr__() is not None)
 
 
-class OSSMockHttp(MockHttp):
+class OSSMockHttp(MockHttp, unittest.TestCase):
 
     fixtures = StorageFileFixtures('oss')
     base_headers = {}
@@ -233,7 +233,7 @@ class OSSMockHttp(MockHttp):
                 headers,
                 httplib.responses[httplib.OK])
 
-    def _foo_bar_object(self, method, url, body, headers):
+    def _foo_bar_object_delete(self, method, url, body, headers):
         # test_delete_object
         return (httplib.NO_CONTENT,
                 body,
@@ -598,7 +598,7 @@ class OSSStorageDriverTestCase(unittest.TestCase):
         self.assertTrue(result)
 
     def test_download_object_invalid_file_size(self):
-        self.mock_raw_response_klass.type = 'invalid_size'
+        self.mock_response_klass.type = 'invalid_size'
         container = Container(name='foo_bar_container', extra={},
                               driver=self.driver)
         obj = Object(name='foo_bar_object', size=1000, hash=None, extra={},
@@ -612,7 +612,7 @@ class OSSStorageDriverTestCase(unittest.TestCase):
         self.assertFalse(result)
 
     def test_download_object_not_found(self):
-        self.mock_raw_response_klass.type = 'not_found'
+        self.mock_response_klass.type = 'not_found'
         container = Container(name='foo_bar_container', extra={},
                               driver=self.driver)
         obj = Object(name='foo_bar_object', size=1000, hash=None, extra={},
@@ -642,11 +642,11 @@ class OSSStorageDriverTestCase(unittest.TestCase):
         def upload_file(self, object_name=None, content_type=None,
                         request_path=None, request_method=None,
                         headers=None, file_path=None, stream=None):
-            return {'response': MockResponse(200, headers={'etag': '2345'}),
+            return {'response': make_response(200, headers={'etag': '2345'}),
                     'bytes_transferred': 1000,
                     'data_hash': 'hash343hhash89h932439jsaa89'}
 
-        self.mock_raw_response_klass.type = 'INVALID_HASH1'
+        self.mock_response_klass.type = 'INVALID_HASH1'
 
         old_func = self.driver_type._upload_object
         self.driver_type._upload_object = upload_file
@@ -670,8 +670,8 @@ class OSSStorageDriverTestCase(unittest.TestCase):
         def upload_file(self, object_name=None, content_type=None,
                         request_path=None, request_method=None,
                         headers=None, file_path=None, stream=None):
-            return {'response': MockResponse(200,
-                                             headers={'etag': '0cc175b9c0f1b6a831c399e269772661'}),
+            return {'response': make_response(200,
+                                              headers={'etag': '0cc175b9c0f1b6a831c399e269772661'}),
                     'bytes_transferred': 1000,
                     'data_hash': '0cc175b9c0f1b6a831c399e269772661'}
         self.mock_response_klass.type = None
@@ -696,7 +696,7 @@ class OSSStorageDriverTestCase(unittest.TestCase):
         def upload_file(self, object_name=None, content_type=None,
                         request_path=None, request_method=None,
                         headers=None, file_path=None, stream=None):
-            return {'response': MockResponse(200, headers={'etag': '0cc175b9c0f1b6a831c399e269772661'}),
+            return {'response': make_response(200, headers={'etag': '0cc175b9c0f1b6a831c399e269772661'}),
                     'bytes_transferred': 1000,
                     'data_hash': '0cc175b9c0f1b6a831c399e269772661'}
 
@@ -735,10 +735,8 @@ class OSSStorageDriverTestCase(unittest.TestCase):
 
     def test_upload_empty_object_via_stream(self):
         if self.driver.supports_multipart_upload:
-            self.mock_raw_response_klass.type = 'multipart'
             self.mock_response_klass.type = 'multipart'
         else:
-            self.mock_raw_response_klass.type = None
             self.mock_response_klass.type = None
 
         container = Container(name='foo_bar_container', extra={},
@@ -756,10 +754,8 @@ class OSSStorageDriverTestCase(unittest.TestCase):
 
     def test_upload_small_object_via_stream(self):
         if self.driver.supports_multipart_upload:
-            self.mock_raw_response_klass.type = 'multipart'
             self.mock_response_klass.type = 'multipart'
         else:
-            self.mock_raw_response_klass.type = None
             self.mock_response_klass.type = None
 
         container = Container(name='foo_bar_container', extra={},
@@ -777,10 +773,8 @@ class OSSStorageDriverTestCase(unittest.TestCase):
 
     def test_upload_big_object_via_stream(self):
         if self.driver.supports_multipart_upload:
-            self.mock_raw_response_klass.type = 'multipart'
             self.mock_response_klass.type = 'multipart'
         else:
-            self.mock_raw_response_klass.type = None
             self.mock_response_klass.type = None
 
         container = Container(name='foo_bar_container', extra={},
@@ -801,7 +795,6 @@ class OSSStorageDriverTestCase(unittest.TestCase):
         if not self.driver.supports_multipart_upload:
             return
 
-        self.mock_raw_response_klass.type = 'MULTIPART'
         self.mock_response_klass.type = 'MULTIPART'
 
         def _faulty_iterator():
@@ -866,6 +859,7 @@ class OSSStorageDriverTestCase(unittest.TestCase):
                           obj=obj)
 
     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,


Mime
View raw message