def test_deletes_failing_to_connect_to_lms(self, mock_post_to_lms, mock_logger): "Retire all the submissions, and fail the LMS callback" bulk_create_submissions(5) self.count_unretired(5) call_command('retire_old_submissions', 'test') mock_logger.error.assert_called() logs, _ = mock_logger.error.call_args self.assertRegexpMatches( logs[0], r'Could not contact LMS to retire submission') self.count_unretired(0)
def test_undeleted(self, mock_post_to_lms): """ Create some older submissions and only retire those old ones Defaults are 10 days old, add 4 day old ones and retire anything 5 days or older """ bulk_create_submissions(5, 4) bulk_create_submissions(5) self.count_unretired(10) older = timezone.now() - timedelta(5) call_command('retire_old_submissions', 'test', retire_before=older.isoformat()) self.count_unretired(5)
def test_deletes(self, mock_post_to_lms): "Retire all the submissions" bulk_create_submissions(5) self.count_unretired(5) call_command('retire_old_submissions', 'test') self.count_unretired(0)
def test_days_old(self): bulk_create_submissions(20) self.assertEquals(Submission.objects.count(), 20) call_command('delete_old_submissions', days_old=2) self.assertEquals(Submission.objects.count(), 0)
def test_chunks(self): bulk_create_submissions(20) call_command('delete_old_submissions', chunk_size=5, sleep_between=1) self.assertEquals(Submission.objects.count(), 0)
def test_undeleted(self): bulk_create_submissions(15, 5) bulk_create_submissions(15) self.assertEquals(Submission.objects.count(), 30) call_command('delete_old_submissions') self.assertEquals(Submission.objects.count(), 15)
def test_deletes(self): "Default is 10 days old, default is deleting older than 7 days" bulk_create_submissions(30) self.assertEquals(Submission.objects.count(), 30) call_command('delete_old_submissions') self.assertEquals(Submission.objects.count(), 0)