Move retry test file to common/ directory since this functionality is not
specific to compute drivers.


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

Branch: refs/heads/trunk
Commit: 5f870dbfb30deb32970010b81e89b29fcff9daaa
Parents: 6ffffa3
Author: Tomaz Muraus <[email protected]>
Authored: Sun Jul 19 17:31:32 2015 +0800
Committer: Tomaz Muraus <[email protected]>
Committed: Sun Jul 19 17:31:44 2015 +0800

----------------------------------------------------------------------
 libcloud/test/common/test_retry_limit.py  | 76 ++++++++++++++++++++++++++
 libcloud/test/compute/test_retry_limit.py | 76 --------------------------
 2 files changed, 76 insertions(+), 76 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/5f870dbf/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
new file mode 100644
index 0000000..72e3710
--- /dev/null
+++ b/libcloud/test/common/test_retry_limit.py
@@ -0,0 +1,76 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import socket
+import tempfile
+
+from mock import Mock, patch, MagicMock
+
+from libcloud.utils.py3 import httplib
+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 = [
+    ('status', '429'), ('reason', 'CONFLICT'),
+    ('retry_after', '3'),
+    ('content-type', 'application/json')]
+SIMPLE_RESPONSE_STATUS = ('HTTP/1.1', 429, 'CONFLICT')
+
+
+class FailedRequestRetryTestCase(unittest.TestCase):
+
+    def _raise_socket_error(self):
+        raise socket.gaierror('')
+
+    def test_retry_connection(self):
+        con = Connection(timeout=1, retry_delay=0.1)
+        con.connection = Mock()
+        connect_method = 'libcloud.common.base.Connection.request'
+
+        with patch(connect_method) as mock_connect:
+            try:
+                mock_connect.side_effect = socket.gaierror('')
+                con.request('/')
+            except socket.gaierror:
+                pass
+            except Exception:
+                self.fail('Failed to raise socket exception')
+
+    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/5f870dbf/libcloud/test/compute/test_retry_limit.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_retry_limit.py 
b/libcloud/test/compute/test_retry_limit.py
deleted file mode 100644
index 72e3710..0000000
--- a/libcloud/test/compute/test_retry_limit.py
+++ /dev/null
@@ -1,76 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import socket
-import tempfile
-
-from mock import Mock, patch, MagicMock
-
-from libcloud.utils.py3 import httplib
-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 = [
-    ('status', '429'), ('reason', 'CONFLICT'),
-    ('retry_after', '3'),
-    ('content-type', 'application/json')]
-SIMPLE_RESPONSE_STATUS = ('HTTP/1.1', 429, 'CONFLICT')
-
-
-class FailedRequestRetryTestCase(unittest.TestCase):
-
-    def _raise_socket_error(self):
-        raise socket.gaierror('')
-
-    def test_retry_connection(self):
-        con = Connection(timeout=1, retry_delay=0.1)
-        con.connection = Mock()
-        connect_method = 'libcloud.common.base.Connection.request'
-
-        with patch(connect_method) as mock_connect:
-            try:
-                mock_connect.side_effect = socket.gaierror('')
-                con.request('/')
-            except socket.gaierror:
-                pass
-            except Exception:
-                self.fail('Failed to raise socket exception')
-
-    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()

Reply via email to