示例#1
0
    def testValid(self):
        oneweek = datetime.now() + timedelta(days=7)
        data = utils.create(self.user, usage_left=1, expires=oneweek)
        self.assertEqual(len(Key.objects.all()), 1)

        utils.cleanup()
        self.assertEqual(len(Key.objects.all()), 1)
示例#2
0
    def testExpired(self):
        oneweekago = timezone.now() - timedelta(days=7)
        data = utils.create(self.user, usage_left=1, expires=oneweekago)
        self.assertEqual(len(Key.objects.all()), 1)

        utils.cleanup()
        self.assertEqual(len(Key.objects.all()), 0)
示例#3
0
    def testValid(self):
        oneweek = timezone.now() + timedelta(days=7)
        data = utils.create(self.user, usage_left=1, expires=oneweek)
        self.assertEqual(len(Key.objects.all()), 1)

        utils.cleanup()
        self.assertEqual(len(Key.objects.all()), 1)
示例#4
0
    def testExpired(self):
        oneweekago = datetime.now() - timedelta(days=7)
        data = utils.create(self.user, usage_left=1, expires=oneweekago)
        self.assertEqual(len(Key.objects.all()), 1)

        utils.cleanup()
        self.assertEqual(len(Key.objects.all()), 0)
示例#5
0
    def testNegative(self):
        data = utils.create(self.user, usage_left=-1)
        self.assertEqual(len(Key.objects.all()), 1)

        utils.cleanup()
        self.assertEqual(len(Key.objects.all()), 0)
示例#6
0
    def testAlwaysValid(self):
        data = utils.create(self.user, usage_left=None, expires=None)
        self.assertEqual(len(Key.objects.all()), 1)

        utils.cleanup()
        self.assertEqual(len(Key.objects.all()), 1)
示例#7
0
def cleanup(request):
    """
    Remove expired keys.
    """
    utils.cleanup()
    return HttpResponse('ok', content_type='text/plain')
示例#8
0
    def testAlwaysValid(self):
        data = utils.create(self.user, usage_left=None, expires=None)
        self.assertEqual(len(Key.objects.all()), 1)

        utils.cleanup()
        self.assertEqual(len(Key.objects.all()), 1)
示例#9
0
    def testNegative(self):
        data = utils.create(self.user, usage_left=-1)
        self.assertEqual(len(Key.objects.all()), 1)

        utils.cleanup()
        self.assertEqual(len(Key.objects.all()), 0)
 def handle_noargs(self, **options):
     from loginurl import utils
     utils.cleanup()
示例#11
0
def cleanup(request):
    """
    Remove expired keys.
    """
    utils.cleanup()
    return HttpResponse('ok', content_type='text/plain')
示例#12
0
 def handle(self, *args, **kwargs):
     from loginurl import utils
     utils.cleanup()
示例#13
0
 def handle_noargs(self, **options):
     from loginurl import utils
     utils.cleanup()