Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 80915200C64 for ; Thu, 13 Apr 2017 11:33:12 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 7F637160B8B; Thu, 13 Apr 2017 09:33:12 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 7D824160BBD for ; Thu, 13 Apr 2017 11:33:08 +0200 (CEST) Received: (qmail 73210 invoked by uid 500); 13 Apr 2017 09:33:07 -0000 Mailing-List: contact notifications-help@libcloud.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@libcloud.apache.org Delivered-To: mailing list notifications@libcloud.apache.org Received: (qmail 72746 invoked by uid 500); 13 Apr 2017 09:33:07 -0000 Delivered-To: apmail-libcloud-commits@libcloud.apache.org Received: (qmail 72687 invoked by uid 99); 13 Apr 2017 09:33:07 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Apr 2017 09:33:07 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 746E4E027A; Thu, 13 Apr 2017 09:33:07 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: anthonyshaw@apache.org To: commits@libcloud.apache.org Date: Thu, 13 Apr 2017 09:33:27 -0000 Message-Id: In-Reply-To: <8ec60eca15fa476d93d0a42695bb4aaa@git.apache.org> References: <8ec60eca15fa476d93d0a42695bb4aaa@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [21/46] libcloud git commit: fix oss tests archived-at: Thu, 13 Apr 2017 09:33:12 -0000 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 Authored: Wed Apr 12 10:57:38 2017 +1000 Committer: Anthony Shaw 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,