def finalize_response(self, request, response, *args, **kwargs): """ Returns the final response object. """ # By this time the local user has been recorded if necessary. clear_local_user() return super().finalize_response(request, response, *args, **kwargs)
def test_audit_no_user(self): clear_local_user() with LogCapture(level=logging.INFO) as log_capture: # test self.test_model._meta.fields.update( {'description': "it's a round window"}) self.test_model.save() # check self.assertEqual(0, Audit.objects.count()) log_capture.check(( 'automationcommon', 'WARNING', "Don't know who made this change: (model=TestModel:1, field=description, " "old='it's round', new='it's a round window')"), ('automationcommon', 'WARNING', LOCAL_USER_WARNING))
def tearDown(self): clear_local_user()
def process_exception(cls, request, exception): """ Clear the user to minimise the chance of a user being wrongly assigned. """ clear_local_user()
def process_response(cls, request, response): """ Clear the user to minimise the chance of a user being wrongly assigned. """ clear_local_user() return response