Exemple #1
0
 def test_active_accounts_are_not_deleted(self):
     # TEST 1: active with date_joined older than deadline NOT deleted
     self.bob.date_joined -= self.TIMEDELTA
     self.bob.save()
     num_deleted = prune_invalid_users()
     self.assertEqual(num_deleted, 0)
     self.assertTrue(User.objects.filter(username='******').exists())
Exemple #2
0
 def test_activatable_accounts_are_not_deleted(self):
     # TEST 3: inactive, never logged in, before deadline NOT deleted
     self.bob.is_active = False
     self.bob.save()
     num_deleted = prune_invalid_users()
     self.assertEqual(num_deleted, 0)
     self.assertTrue(User.objects.filter(username='******').exists())
Exemple #3
0
 def test_inactive_unused_accounts_are_deleted(self):
     # TEST 4: inactive, never logged in, older than deadline deleted
     self.bob.date_joined -= self.TIMEDELTA
     self.bob.is_active = False
     self.bob.save()
     num_deleted = prune_invalid_users()
     self.assertEqual(num_deleted, 1)
     self.assertFalse(User.objects.filter(username='******').exists())
Exemple #4
0
 def test_inactive_but_used_accounts_are_not_deleted(self):
     # TEST 2: inactive but already logged in with date_joined older than deadline NOT deleted
     self.bob.date_joined -= self.TIMEDELTA
     self.bob.last_login = self.bob.date_joined
     self.bob.is_active = False
     self.bob.save()
     num_deleted = prune_invalid_users()
     self.assertEqual(num_deleted, 0)
     self.assertTrue(User.objects.filter(username='******').exists())
Exemple #5
0
def autoprune_invalid_users():
    num_deleted = prune_invalid_users()
    logger.info(f'Pruned {num_deleted} invalid account(s).')
Exemple #6
0
 def handle(self, *args, **options):
     num_deleted = prune_invalid_users()
     self.stdout.write(f'Pruned {num_deleted} invalid account(s).')