|
@@ -411,7 +411,7 @@ class TestManagementCommands(TestCase):
|
|
|
longitude=0.5,
|
|
|
)
|
|
|
contrib.expiration_date = datetime.datetime(
|
|
|
- 2010, 10, 10, tzinfo=pytz.utc)
|
|
|
+ 2010, 10, 10, 1, 0, tzinfo=pytz.utc)
|
|
|
contrib.save()
|
|
|
|
|
|
@override_settings(DATA_EXPIRATION_REMINDERS=[10])
|
|
@@ -419,16 +419,35 @@ class TestManagementCommands(TestCase):
|
|
|
# 11 days before (should not send)
|
|
|
with freeze_time('29-09-2010', tz_offset=0):
|
|
|
call_command('send_expiration_reminders')
|
|
|
- self.assertEqual(len(mail.outbox), 0)
|
|
|
+ self.assertEqual(Contrib.objects.count(), 1)
|
|
|
|
|
|
# 9 days before (should not send)
|
|
|
with freeze_time('01-10-2010', tz_offset=0):
|
|
|
call_command('send_expiration_reminders')
|
|
|
- self.assertEqual(len(mail.outbox), 0)
|
|
|
+ self.assertEqual(Contrib.objects.count(), 1)
|
|
|
|
|
|
# 10 days before (should send)
|
|
|
with freeze_time('30-09-2010', tz_offset=0):
|
|
|
call_command('send_expiration_reminders', '--dry-run')
|
|
|
- self.assertEqual(len(mail.outbox), 0)
|
|
|
+ self.assertEqual(Contrib.objects.count(), 1)
|
|
|
call_command('send_expiration_reminders')
|
|
|
self.assertEqual(len(mail.outbox), 1)
|
|
|
+
|
|
|
+ def test_delete_expired_contribs(self):
|
|
|
+ # 1 days before expiration
|
|
|
+ with freeze_time('09-09-2010', tz_offset=0):
|
|
|
+ call_command('delete_expired_contribs')
|
|
|
+ self.assertEqual(Contrib.objects.count(), 1)
|
|
|
+
|
|
|
+ # expiration day
|
|
|
+ with freeze_time('10-10-2010 23:59', tz_offset=0):
|
|
|
+ call_command('delete_expired_contribs', '--dry-run')
|
|
|
+ self.assertEqual(Contrib.objects.count(), 1)
|
|
|
+ call_command('delete_expired_contribs')
|
|
|
+ self.assertEqual(Contrib.objects.count(), 0)
|
|
|
+
|
|
|
+ self.setUp()
|
|
|
+ # 1 day after expiration
|
|
|
+ with freeze_time('11-10-2010', tz_offset=0):
|
|
|
+ call_command('delete_expired_contribs')
|
|
|
+ self.assertEqual(Contrib.objects.count(), 0)
|