def test_log(): m = CrashLogMiddleware() factory = RequestFactory() request = factory.get("/my/home/url") request.user = AnonymousUser() request.session = {} m.process_exception(request, PermissionDenied()) assert Error.objects.filter(class_name='PermissionDenied').exists()
def test_ignore_class(): m = CrashLogMiddleware() factory = RequestFactory() request = factory.get("/my/home/url") request.session = {} with override_settings(CRASHLOG_IGNORE_EXCEPTIONS=[ 'django.core.exceptions.PermissionDenied' ]): m.process_exception(request, PermissionDenied()) assert not Error.objects.filter(class_name='PermissionDenied').exists()
def test_return_value(): m = CrashLogMiddleware() factory = RequestFactory() request = factory.get("/my/home/url") ret = m.process_exception(request, PermissionDenied()) assert isinstance(ret, HttpResponse) or ret is None