libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anthonys...@apache.org
Subject [33/33] libcloud git commit: Fix remaining test classes
Date Tue, 05 Apr 2016 11:17:24 GMT
Fix remaining test classes


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

Branch: refs/heads/requests
Commit: 2519c34d7b375618d96ca60902e33b4d17f29dbe
Parents: 04d4655
Author: anthony-shaw <anthony.p.shaw@gmail.com>
Authored: Tue Apr 5 18:25:03 2016 +1000
Committer: anthony-shaw <anthony.p.shaw@gmail.com>
Committed: Tue Apr 5 18:25:03 2016 +1000

----------------------------------------------------------------------
 libcloud/common/base.py                  |  9 +++------
 libcloud/test/common/test_nfsn.py        |  2 +-
 libcloud/test/common/test_retry_limit.py | 26 --------------------------
 libcloud/utils/loggingconnection.py      |  1 +
 4 files changed, 5 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/2519c34d/libcloud/common/base.py
----------------------------------------------------------------------
diff --git a/libcloud/common/base.py b/libcloud/common/base.py
index b1ec3d9..2479394 100644
--- a/libcloud/common/base.py
+++ b/libcloud/common/base.py
@@ -36,7 +36,7 @@ import requests
 
 import libcloud
 
-from libcloud.utils.py3 import PY25, basestring
+from libcloud.utils.py3 import PY25
 from libcloud.utils.py3 import httplib
 from libcloud.utils.py3 import urlparse
 from libcloud.utils.py3 import urlencode
@@ -152,11 +152,8 @@ class Response(object):
         self.error = response.reason
         self.status = response.status_code
 
-        if isinstance(response.text, basestring):
-            self.body = response.text.strip() \
-                if response.text is not None else ''
-        else:
-            self.body = ''
+        self.body = response.text.strip() \
+            if response.text is not None else ''
 
         if not self.success():
             raise exception_from_message(code=self.status,

http://git-wip-us.apache.org/repos/asf/libcloud/blob/2519c34d/libcloud/test/common/test_nfsn.py
----------------------------------------------------------------------
diff --git a/libcloud/test/common/test_nfsn.py b/libcloud/test/common/test_nfsn.py
index 5e77f32..8295f00 100644
--- a/libcloud/test/common/test_nfsn.py
+++ b/libcloud/test/common/test_nfsn.py
@@ -20,7 +20,7 @@ mock_header = 'testid;1000000;yumsalty1234;66dfb282a9532e5b8e6a9517764d5fbc001a4
 class NFSNConnectionTestCase(LibcloudTestCase):
 
     def setUp(self):
-        NFSNConnection.conn_classes = (None, NFSNMockHttp)
+        NFSNConnection.conn_class = NFSNMockHttp
         NFSNMockHttp.type = None
         self.driver = NFSNConnection('testid', 'testsecret')
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/2519c34d/libcloud/test/common/test_retry_limit.py
----------------------------------------------------------------------
diff --git a/libcloud/test/common/test_retry_limit.py b/libcloud/test/common/test_retry_limit.py
index 06eac2a..f57ccb3 100644
--- a/libcloud/test/common/test_retry_limit.py
+++ b/libcloud/test/common/test_retry_limit.py
@@ -14,16 +14,12 @@
 # limitations under the License.
 
 import socket
-import tempfile
 import ssl
 
 from mock import Mock, patch, MagicMock
 
-from libcloud.utils.py3 import httplib
 from libcloud.utils.misc import TRANSIENT_SSL_ERROR
 from libcloud.common.base import Connection
-from libcloud.common.base import Response
-from libcloud.common.exceptions import RateLimitReachedError
 from libcloud.test import unittest
 
 CONFLICT_RESPONSE_STATUS = [
@@ -65,27 +61,5 @@ class FailedRequestRetryTestCase(unittest.TestCase):
                 self.assertRaises(ssl.SSLError, conn.request, '/')
                 self.assertGreater(connection.request.call_count, 1)
 
-    def test_rate_limit_error(self):
-        sock = Mock()
-        con = Connection()
-
-        try:
-            with patch('libcloud.utils.py3.httplib.HTTPResponse.getheaders',
-                       MagicMock(return_value=CONFLICT_RESPONSE_STATUS)):
-                with patch(
-                        'libcloud.utils.py3.httplib.HTTPResponse._read_status',
-                        MagicMock(return_value=SIMPLE_RESPONSE_STATUS)):
-                    with tempfile.TemporaryFile(mode='w+b') as f:
-                        f.write('HTTP/1.1 429 CONFLICT\n'.encode())
-                        f.flush()
-                        sock.makefile = Mock(return_value=f)
-                        mock_obj = httplib.HTTPResponse(sock)
-                        mock_obj.begin()
-                        Response(mock_obj, con)
-        except RateLimitReachedError:
-            pass
-        except Exception:
-            self.fail('Failed to raise Rate Limit exception')
-
 if __name__ == '__main__':
     unittest.main()

http://git-wip-us.apache.org/repos/asf/libcloud/blob/2519c34d/libcloud/utils/loggingconnection.py
----------------------------------------------------------------------
diff --git a/libcloud/utils/loggingconnection.py b/libcloud/utils/loggingconnection.py
index 966023a..71931b0 100644
--- a/libcloud/utils/loggingconnection.py
+++ b/libcloud/utils/loggingconnection.py
@@ -175,6 +175,7 @@ class LoggingConnection(LoggingBaseConnection, LibcloudConnection):
     """
 
     protocol = 'https'
+    port = None
 
     def getresponse(self):
         r = LibcloudConnection.getresponse(self)


Mime
View raw message