def test_request_passes_test_False(self): test_func = self.test_func view_func = self.view_func test_func.return_value = False decorated = request_passes_test(test_func) self.assertEqual(test_func(0), False) self.assertEqual(view_func(0), 'passed') self.assertEqual(type(decorated(view_func)(self.request)), HttpResponseRedirect)
def test_request_passes_test_True(self): test_func = self.test_func view_func = self.view_func decorated = request_passes_test(test_func) self.assertEqual(test_func(0), True) self.assertEqual(view_func(0), 'passed') self.assertEqual(decorated(view_func)(self.request), 'passed') self.assertEqual(decorated(view_func)(self.request, 's'), 'passed') self.assertEqual(decorated(view_func)(self.request, pk='1'), 'passed') self.assertEqual(decorated(view_func)(self.request, pk='2'), 'passed')