def test_draw_with_schedule(self): self.draw.schedule_toss(NOW + dt.timedelta(days=30)) self.tick() deleted = purge.delete_old_records() assert deleted == 0 self.tick(30) deleted = purge.delete_old_records() assert deleted == 1
def test_draw_with_results(self): self.draw.toss() self.draw.toss() self.draw.toss() deleted = purge.delete_old_records() assert deleted == 0 self.tick() deleted = purge.delete_old_records() assert deleted == 1
def test_draw_without_results(self): deleted = purge.delete_old_records() assert deleted == 0 self.tick(60) deleted = purge.delete_old_records() assert deleted == 0 self.tick(31) deleted = purge.delete_old_records() assert deleted == 1
def test_purge_old_secret_santa(self): with freezegun.freeze_time(NOW) as time: result = models.SecretSantaResult(source="From name", target="To name") result.save() deleted = purge.delete_old_records() assert deleted == 0 time.tick(delta=dt.timedelta(days=31 * 3)) deleted = purge.delete_old_records() assert deleted == 1
def test_multiple(self): self.draw1 = self.create() self.draw2 = self.create() self.tick() deleted = purge.delete_old_records() assert deleted == 3
def test_multiple_new_result_not_deleted(self): self.draw1 = self.create() self.draw2 = self.create() self.tick() self.draw.toss() deleted = purge.delete_old_records() assert deleted == 2
def purge(self): purge.delete_old_records(days_to_keep=-500)
def test_far_future_schedule_result_not_deleted(self): self.draw.schedule_toss(NOW + dt.timedelta(days=300)) self.tick() deleted = purge.delete_old_records() assert deleted == 0