You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by an...@apache.org on 2017/05/05 11:46:32 UTC
[13/20] libcloud git commit: add test for connection method thing
add test for connection method thing
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/36ee4efa
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/36ee4efa
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/36ee4efa
Branch: refs/heads/trunk
Commit: 36ee4efa531b25b7f50fa373f17bfa91a671b796
Parents: f35ff79
Author: Anthony Shaw <an...@apache.org>
Authored: Fri May 5 20:03:37 2017 +1000
Committer: Anthony Shaw <an...@apache.org>
Committed: Fri May 5 20:03:37 2017 +1000
----------------------------------------------------------------------
libcloud/test/compute/test_indosat.py | 28 ++++++++++++++++++++
libcloud/test/compute/test_internetsolutions.py | 28 ++++++++++++++++++++
libcloud/test/test_utils.py | 10 ++++++-
3 files changed, 65 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/36ee4efa/libcloud/test/compute/test_indosat.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_indosat.py b/libcloud/test/compute/test_indosat.py
new file mode 100644
index 0000000..84bd765
--- /dev/null
+++ b/libcloud/test/compute/test_indosat.py
@@ -0,0 +1,28 @@
+# 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 unittest
+
+from libcloud.compute.drivers.indosat import IndosatNodeDriver
+from libcloud.test.compute.test_dimensiondata_v2_3 import DimensionDataMockHttp, DimensionData_v2_3_Tests
+
+
+class IndosatNodeDriverTests(DimensionData_v2_3_Tests, unittest.TestCase):
+
+ def setUp(self):
+ IndosatNodeDriver.connectionCls.conn_class = DimensionDataMockHttp
+ IndosatNodeDriver.connectionCls.active_api_version = '2.3'
+ DimensionDataMockHttp.type = None
+ self.driver = IndosatNodeDriver('user', 'password')
http://git-wip-us.apache.org/repos/asf/libcloud/blob/36ee4efa/libcloud/test/compute/test_internetsolutions.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_internetsolutions.py b/libcloud/test/compute/test_internetsolutions.py
new file mode 100644
index 0000000..9f644d2
--- /dev/null
+++ b/libcloud/test/compute/test_internetsolutions.py
@@ -0,0 +1,28 @@
+# 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 unittest
+
+from libcloud.compute.drivers.internetsolutions import InternetSolutionsNodeDriver
+from libcloud.test.compute.test_dimensiondata_v2_3 import DimensionDataMockHttp, DimensionData_v2_3_Tests
+
+
+class InternetSolutionsNodeDriverTests(DimensionData_v2_3_Tests, unittest.TestCase):
+
+ def setUp(self):
+ InternetSolutionsNodeDriver.connectionCls.conn_class = DimensionDataMockHttp
+ InternetSolutionsNodeDriver.connectionCls.active_api_version = '2.3'
+ DimensionDataMockHttp.type = None
+ self.driver = InternetSolutionsNodeDriver('user', 'password')
http://git-wip-us.apache.org/repos/asf/libcloud/blob/36ee4efa/libcloud/test/test_utils.py
----------------------------------------------------------------------
diff --git a/libcloud/test/test_utils.py b/libcloud/test/test_utils.py
index d92e353..5f866fd 100644
--- a/libcloud/test/test_utils.py
+++ b/libcloud/test/test_utils.py
@@ -21,7 +21,7 @@ import codecs
import unittest
import warnings
import os.path
-
+import requests_mock
from itertools import chain
# In Python > 2.7 DeprecationWarnings are disabled by default
@@ -46,6 +46,7 @@ from libcloud.utils.networking import is_valid_ip_address
from libcloud.utils.networking import join_ipv4_segments
from libcloud.utils.networking import increment_ipv4_segments
from libcloud.utils.decorators import wrap_non_libcloud_exceptions
+from libcloud.utils.connection import get_response_object
from libcloud.common.types import LibcloudError
from libcloud.storage.drivers.dummy import DummyIterator
@@ -393,5 +394,12 @@ def test_decorator():
with pytest.raises(LibcloudError):
foo()
+
+def test_get_response_object():
+ with requests_mock.mock() as m:
+ m.get('http://test.com/test', text='data')
+ response = get_response_object('http://test.com/test')
+ assert response.body == 'data'
+
if __name__ == '__main__':
sys.exit(unittest.main())