Example #1
0
 def process_response(self, request, response):
     if 'test_client_true' not in request.REQUEST \
     and SHOW_TESTMAKER_HEADER:
         c = Context({'file': Testmaker.logfile()})
         s = RESPONSE_TEMPLATE.render(c)
         response.content = str(s) + str(response.content)
     return response
Example #2
0
 def process_request(self, request):
     """
     Run the request through the testmaker middleware.
     This outputs the requests to the chosen Serializers.
     Possible running it through one or many Processors
     """
     # This is request.REQUEST to catch POST and GET
     if 'test_client_true' not in request.GET:
         request.logfile = Testmaker.logfile()
         self.serializer.save_request(request)
         self.processor.save_request(request)
         # We only want to re-run the request on idempotent requests
         if request.method.lower() == "get":
             try:
                 setup_test_environment()
                 c = Client(REMOTE_ADDR='127.0.0.1')
                 getdict = request.GET.copy()
                 getdict['test_client_true'] = 'yes'  # avoid recursion
                 response = c.get(request.path, getdict)
                 self.serializer.save_response(request, response)
                 self.processor.save_response(request, response)
                 teardown_test_environment()
             except RuntimeError:
                 teardown_test_environment()
                 setup_test_environment()
                 c = Client(REMOTE_ADDR='127.0.0.1')
                 getdict = request.GET.copy()
                 getdict['test_client_true'] = 'yes'  # avoid recursion
                 response = c.get(request.path, getdict)
                 self.serializer.save_response(request, response)
                 self.processor.save_response(request, response)
                 teardown_test_environment()
     return None
Example #3
0
 def process_response(self, request, response):
     if 'test_client_true' not in request.REQUEST \
     and SHOW_TESTMAKER_HEADER:
         c = Context({'file': Testmaker.logfile()})
         s = RESPONSE_TEMPLATE.render(c)
         response.content = str(s) + str(response.content)
     return response
 def process_request(self, request):
     """
     Run the request through the testmaker middleware.
     This outputs the requests to the chosen Serializers.
     Possible running it through one or many Processors
     """
     # This is request.REQUEST to catch POST and GET
     if "test_client_true" not in request.REQUEST:
         request.logfile = Testmaker.logfile()
         self.serializer.save_request(request)
         self.processor.save_request(request)
         # We only want to re-run the request on idempotent requests
         if request.method.lower() == "get":
             setup_test_environment()
             c = Client(REMOTE_ADDR="127.0.0.1")
             getdict = request.GET.copy()
             getdict["test_client_true"] = "yes"  # avoid recursion
             response = c.get(request.path, getdict)
             self.serializer.save_response(request, response)
             self.processor.save_response(request, response)
     return None
Example #5
0
def show_log(request):
    file = Testmaker.logfile()
    contents = open(file)
    return HttpResponse(contents.read(), content_type='text/plain')
    HttpResponse()