Example #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")
Example #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")
Example #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()))
Example #4
0
 def test_base_response(self):
     Response(MockResponse(status=200, body='foo'), ConnectionKey('foo'))
Example #5
0
 def test_base_response(self):
     Response(MockResponse(status=200, body='foo'))