libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject [1/2] libcloud git commit: Add failing regression test case for timeout argument preservation on the BaseDriver class.
Date Fri, 15 Apr 2016 19:12:11 GMT
Repository: libcloud
Updated Branches:
  refs/heads/ex_connection_class_kwargs_regression_fix [created] fd0a22fea


Add failing regression test case for timeout argument preservation on the
BaseDriver class.


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

Branch: refs/heads/ex_connection_class_kwargs_regression_fix
Commit: 3ccd2e71b314ba63c3df9f43635c92d996b5fed8
Parents: 8185276
Author: Tomaz Muraus <tomaz@tomaz.me>
Authored: Fri Apr 15 21:02:24 2016 +0200
Committer: Tomaz Muraus <tomaz@tomaz.me>
Committed: Fri Apr 15 21:02:39 2016 +0200

----------------------------------------------------------------------
 libcloud/test/common/test_base_driver.py | 59 +++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/3ccd2e71/libcloud/test/common/test_base_driver.py
----------------------------------------------------------------------
diff --git a/libcloud/test/common/test_base_driver.py b/libcloud/test/common/test_base_driver.py
new file mode 100644
index 0000000..37f15a1
--- /dev/null
+++ b/libcloud/test/common/test_base_driver.py
@@ -0,0 +1,59 @@
+# 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 sys
+
+from mock import Mock
+
+from libcloud.common.base import BaseDriver
+
+from libcloud.test import unittest
+
+
+class BaseDriverTestCase(unittest.TestCase):
+    def test_timeout_argument_propagation_and_preservation(self):
+        class DummyDriver1(BaseDriver):
+            pass
+
+        # 1. No timeout provided
+        DummyDriver1.connectionCls = Mock()
+        DummyDriver1(key='foo')
+        call_kwargs = DummyDriver1.connectionCls.call_args[1]
+        self.assertEqual(call_kwargs['timeout'], None)
+
+        # 2. Timeout provided as constructor argument
+        class DummyDriver1(BaseDriver):
+            pass
+
+        DummyDriver1.connectionCls = Mock()
+        DummyDriver1(key='foo', timeout=12)
+        call_kwargs = DummyDriver1.connectionCls.call_args[1]
+        self.assertEqual(call_kwargs['timeout'], 12)
+
+        # 3. timeout provided via "_ex_connection_class_kwargs" method
+        class DummyDriver2(BaseDriver):
+            def _ex_connection_class_kwargs(self):
+                result = {}
+                result['timeout'] = 13
+                return result
+
+        DummyDriver2.connectionCls = Mock()
+        DummyDriver1(key='foo')
+        call_kwargs = DummyDriver1.connectionCls.call_args[1]
+        self.assertEqual(call_kwargs['timeout'], 13)
+
+
+if __name__ == '__main__':
+    sys.exit(unittest.main())


Mime
View raw message