Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #7
0
def cleanup(request):
    """
    Remove expired keys.
    """
    utils.cleanup()
    return HttpResponse('ok', content_type='text/plain')
Beispiel #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)
Beispiel #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()
Beispiel #11
0
def cleanup(request):
    """
    Remove expired keys.
    """
    utils.cleanup()
    return HttpResponse('ok', content_type='text/plain')
Beispiel #12
0
 def handle(self, *args, **kwargs):
     from loginurl import utils
     utils.cleanup()
Beispiel #13
0
 def handle_noargs(self, **options):
     from loginurl import utils
     utils.cleanup()