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