Example #1
0
 def test_log_response_connected(self):
     expected_code = 200
     expected_data = "data"
     expected_debug_data = "* text\n>> data out\n"
     response = Response.connection_successful(
         MockCurlSimple(
             info={pycurl.RESPONSE_CODE: expected_code},
             output=expected_data.encode("utf-8"),
             debug_output=expected_debug_data.encode("utf-8"),
             request=fixture_request(),
         )
     )
     self.com_logger.log_response(response)
     self.reporter.assert_reports(
         fixture_report_item_list_on_success(
             response.request.url,
             expected_code,
             expected_data,
             expected_debug_data
         )
     )
     logger_calls = fixture_logger_calls_on_success(
         response.request.url,
         expected_code,
         expected_data,
         expected_debug_data
     )
     self.assertEqual(logger_calls, self.logger.mock_calls)
 def fixture_response_connected(self, response_code):
     handle = MockCurl({pycurl.RESPONSE_CODE: response_code})
     handle.request_obj = Request(RequestTarget(self.host),
                                  RequestData(self.request))
     handle.output_buffer = io.BytesIO()
     handle.output_buffer.write(self.data)
     return Response.connection_successful(handle)
 def fixture_response_connected(self, response_code):
     handle = MockCurl({pycurl.RESPONSE_CODE: response_code})
     handle.request_obj = Request(
         RequestTarget(self.host), RequestData(self.request)
     )
     handle.output_buffer = io.BytesIO()
     handle.output_buffer.write(self.data)
     return Response.connection_successful(handle)