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/04/13 09:33:33 UTC

[27/46] libcloud git commit: fix openstack tests.

fix openstack tests.


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

Branch: refs/heads/trunk
Commit: 404e73a7252d41a5c572f89916544029b1e4d08d
Parents: d8da3fe
Author: Anthony Shaw <an...@apache.org>
Authored: Wed Apr 12 14:56:41 2017 +1000
Committer: Anthony Shaw <an...@apache.org>
Committed: Wed Apr 12 14:56:41 2017 +1000

----------------------------------------------------------------------
 libcloud/test/__init__.py               |  3 ++-
 libcloud/test/compute/test_openstack.py | 32 ++--------------------------
 2 files changed, 4 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/404e73a7/libcloud/test/__init__.py
----------------------------------------------------------------------
diff --git a/libcloud/test/__init__.py b/libcloud/test/__init__.py
index d5c295b..6371843 100644
--- a/libcloud/test/__init__.py
+++ b/libcloud/test/__init__.py
@@ -220,10 +220,11 @@ class MockConnection(object):
 StorageMockHttp = MockHttp
 
 
-def make_response(status=200, headers={}, connection=None):
+def make_response(status=200, headers={}, body=None, connection=None):
     response = requests.Response()
     response.status_code = status
     response.headers = headers
+    response.text = body
     return Response(response, connection)
 
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/404e73a7/libcloud/test/compute/test_openstack.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_openstack.py b/libcloud/test/compute/test_openstack.py
index bd84143..416380d 100644
--- a/libcloud/test/compute/test_openstack.py
+++ b/libcloud/test/compute/test_openstack.py
@@ -47,7 +47,7 @@ from libcloud.compute.base import Node, NodeImage, NodeSize
 from libcloud.pricing import set_pricing, clear_pricing_data
 
 from libcloud.common.base import Response
-from libcloud.test import MockHttp, XML_HEADERS
+from libcloud.test import MockHttp, XML_HEADERS, make_response
 from libcloud.test.file_fixtures import ComputeFileFixtures, OpenStackFixtures
 from libcloud.test.compute import TestCaseMixin
 
@@ -56,34 +56,6 @@ from libcloud.test.secrets import OPENSTACK_PARAMS
 BASE_DIR = os.path.abspath(os.path.split(__file__)[0])
 
 
-class OpenStack_1_0_ResponseTestCase(unittest.TestCase):
-    XML = """<?xml version="1.0" encoding="UTF-8"?><root/>"""
-
-    def test_simple_xml_content_type_handling(self):
-        http_response = Response(200, 
-                                 OpenStack_1_0_ResponseTestCase.XML, headers={'content-type': 'application/xml'})
-        body = OpenStack_1_0_Response(http_response, None).parse_body()
-
-        self.assertTrue(hasattr(body, 'tag'), "Body should be parsed as XML")
-
-    def test_extended_xml_content_type_handling(self):
-        http_response = Response(200,
-                                 OpenStack_1_0_ResponseTestCase.XML,
-                                 headers={'content-type': 'application/xml; charset=UTF-8'})
-        body = OpenStack_1_0_Response(http_response, None).parse_body()
-
-        self.assertTrue(hasattr(body, 'tag'), "Body should be parsed as XML")
-
-    def test_non_xml_content_type_handling(self):
-        RESPONSE_BODY = "Accepted"
-
-        http_response = Response(202, RESPONSE_BODY, headers={'content-type': 'text/html'})
-        body = OpenStack_1_0_Response(http_response, None).parse_body()
-
-        self.assertEqual(
-            body, RESPONSE_BODY, "Non-XML body should be returned as is")
-
-
 class OpenStack_1_0_Tests(TestCaseMixin):
     should_list_locations = False
     should_list_volumes = False
@@ -1563,7 +1535,7 @@ class OpenStack_1_1_FactoryMethodTests(OpenStack_1_1_Tests):
     driver_kwargs = {'ex_force_auth_version': '2.0'}
 
 
-class OpenStack_1_1_MockHttp(MockHttp):
+class OpenStack_1_1_MockHttp(MockHttp, unittest.TestCase):
     fixtures = ComputeFileFixtures('openstack_v1.1')
     auth_fixtures = OpenStackFixtures()
     json_content_headers = {'content-type': 'application/json; charset=UTF-8'}