def test_remove_expired_jobs(self): buid = 12345 active_jobs = [{'id': 'seo.%s' % i, 'buid': buid} for i in range(4)] old_jobs = [{'id': 'seo.%s' % i, 'buid': buid} for i in range(2, 10)] self.conn.add(old_jobs) self.conn.commit() removed = remove_expired_jobs(buid, [d['id'] for d in active_jobs]) self.assertEqual(len(removed), 6, "Removed jobs %s" % removed) ids = [d['id'] for d in self.conn.search('*:*').docs] self.assertTrue([5, 6, 7, 8, 9, 10] not in ids)
def test_remove_expired_jobs(self): buid = 12345 active_jobs = [{'id': 'seo.%s' % i, 'buid': buid} for i in range(4)] old_jobs = [{'id': 'seo.%s' % i, 'buid': buid} for i in range(2, 10)] with self.settings(HAYSTACK_CONNECTIONS=self.solr_settings): self.solr.add(old_jobs) self.solr.commit() removed = remove_expired_jobs(buid, [d['id'] for d in active_jobs]) self.assertEqual(len(removed), 6, "Removed jobs %s" % removed) ids = [d['id'] for d in self.solr.search('*:*').docs] self.assertTrue([5, 6, 7, 8, 9, 10] not in ids)