def test_view_middleware_valid(self): """ call view when HONEYPOT_VERIFIER returns True """ request = _get_POST_request() request.POST[settings.HONEYPOT_FIELD_NAME] = '' retval = HoneypotViewMiddleware().process_view(request, view_func, (), {}) self.assertEquals(retval, None)
def test_exempt_view(self): """ call view no matter what if view is exempt """ request = _get_POST_request() exempt_view_func = honeypot_exempt(view_func) assert exempt_view_func.honeypot_exempt is True retval = HoneypotViewMiddleware().process_view(request, exempt_view_func, (), {}) self.assertEquals(retval, None)
def test_view_middleware_invalid(self): """ don't call view when HONEYPOT_VERIFIER returns False """ request = _get_POST_request() retval = HoneypotViewMiddleware().process_view(request, view_func, (), {}) self.assertEquals(retval.__class__, HttpResponseBadRequest)