def process_request(self, request): headers_list = [] url_path = request.path method = request.method for key in request.META: if key[:5].lower() == "http_": headers_list.append('%s: %s\n' % (key[5:], request.META[key])) headers = ''.join(headers_list) h = HTTPHeaders(url_path=url_path, method=method, headers=headers) h.save()
def test_signals(self): # ADDITION new_head = HTTPHeaders(url_path='test', method='test', headers='test') new_head.save() log = LogEntry.objects.all().order_by("-action_time")[0] self.assertEqual(log.action_flag is ADDITION, True) self.assertEqual(log.content_type.app_label, 'core') self.assertEqual(log.content_type.model, 'httpheaders') # CHANGE new_head.url_path = 'test edited' new_head.save() log = LogEntry.objects.all().order_by("-action_time")[0] self.assertEqual(log.action_flag is CHANGE, True) self.assertEqual(log.content_type.app_label, 'core') self.assertEqual(log.content_type.model, 'httpheaders') # DELETION new_head.delete() log = LogEntry.objects.all().order_by("-action_time")[0] self.assertEqual(log.action_flag is DELETION, True) self.assertEqual(log.content_type.app_label, 'core') self.assertEqual(log.content_type.model, 'httpheaders')