def test_anonymous_invalid(self): user = User.objects.create_user(username='******', email='test@user') self.request.user = user self.assertFalse(anonymous_condition(True, request=self.request))
def test_request_required(self): with self.assertRaises(RequiredForCondition): anonymous_condition(True)
def test_anonymous_valid(self): self.request.user = AnonymousUser() self.assertTrue(anonymous_condition(True, request=self.request))