예제 #1
0
    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
예제 #2
0
    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
예제 #3
0
    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
예제 #4
0
    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
예제 #5
0
    def test_multiple(self):
        self.draw1 = self.create()
        self.draw2 = self.create()

        self.tick()
        deleted = purge.delete_old_records()
        assert deleted == 3
예제 #6
0
    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
예제 #7
0
 def purge(self):
     purge.delete_old_records(days_to_keep=-500)
예제 #8
0
    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