def test_not_banned(self): IPBlock.objects.create( ip='.'.join(reversed(self.ip.split('.'))), moderator=self.staff, timestamp=Now(), ) self.assertFalse(is_ip_blocked(self.request))
def test_banned(self): IPBlock.objects.create( ip=self.ip, moderator=self.staff, timestamp=Now(), ) self.assertTrue(is_ip_blocked(self.request))
def require_unblocked_ip(request): if is_ip_blocked(request): raise PermissionDenied()