Ejemplo n.º 1
0
def test_callback():
    def callback(req, res):
        global request
        global response
        request = req
        response = res

    forwarder = Forwarder('http://example.com')
    forwarder.on_forward_complete(callback)
    fake_request = object()
    fake_response = object()
    forwarder.trigger_on_forward_complete(fake_request, fake_response)
    assert request == fake_request
    assert response == fake_response
Ejemplo n.º 2
0
def test_callback():
    def callback(req, res):
        global request
        global response
        request = req
        response = res

    forwarder = Forwarder('http://example.com')
    forwarder.on_forward_complete(callback)
    fake_request = object()
    fake_response = object()
    forwarder.trigger_on_forward_complete(fake_request, fake_response)
    assert request == fake_request
    assert response == fake_response
Ejemplo n.º 3
0
 def __init__(self, forward_url, record_file_path):
     forwarder = Forwarder(forward_url)
     self.recorder = HTTPRecorder(record_file_path)
     forwarder.on_forward_complete(lambda req, res: self.recorder.record_http(req, res))
     self._app = forwarder