示例#1
0
    def test_extended_xml_content_type_handling(self):
        http_response = MockResponse(
            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")
示例#2
0
    def test_non_xml_content_type_handling(self):
        RESPONSE_BODY = "Accepted"

        http_response = MockResponse(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")
示例#3
0
 def test_unauthorized_response(self):
     http_response = MockResponse(
         httplib.UNAUTHORIZED,
         OpenNebula_ResponseTests.XML,
         headers={'content-type': 'application/xml'})
     try:
         OpenNebulaResponse(http_response, None).parse_body()
     except InvalidCredsError:
         exceptionType = sys.exc_info()[0]
         self.assertEqual(exceptionType, type(InvalidCredsError()))
示例#4
0
 def test_base_response(self):
     Response(MockResponse(status=200, body='foo'), ConnectionKey('foo'))
示例#5
0
 def test_base_response(self):
     Response(MockResponse(status=200, body='foo'))