Пример #1
0
    def test_can_remove_old_requests(self):
        self.db.query(Request).delete()

        config = Config()
        config.DAYS_TO_KEEP_REQUESTS = 1

        for i in range(4):
            RequestFactory.create(
                url='http://m.com/page-%d' % i,
                domain_name='m.com',
                status_code=200,
                completed_date=date.today() - timedelta(days=i)
            )

        Request.delete_old_requests(self.db, config)

        requests = self.db.query(Request).all()
        expect(requests).to_length(1)
Пример #2
0
    def test_can_remove_old_requests(self):
        self.db.query(Request).delete()

        config = Config()
        config.DAYS_TO_KEEP_REQUESTS = 1

        for i in range(4):
            RequestFactory.create(
                url='http://m.com/page-%d' % i,
                domain_name='m.com',
                status_code=200,
                completed_date=date.today() - timedelta(days=i)
            )

        Request.delete_old_requests(self.db, config)

        requests = self.db.query(Request).all()
        expect(requests).to_length(1)