Exemplo n.º 1
0
 def test_purge(self):
     source_a = 'A'
     source_b = 'B'
     manager = ContentCatalogManager()
     for unit_key, url in self.units(0, 10):
         manager.add_entry(source_a, EXPIRATION, TYPE_ID, unit_key, url)
     for unit_key, url in self.units(0, 10):
         manager.add_entry(source_b, EXPIRATION, TYPE_ID, unit_key, url)
     collection = ContentCatalog.get_collection()
     self.assertEqual(20, collection.find().count())
     manager = ContentCatalogManager()
     manager.purge(source_a)
     self.assertEqual(collection.find({'source_id': source_a}).count(), 0)
     self.assertEqual(collection.find({'source_id': source_b}).count(), 10)
Exemplo n.º 2
0
 def test_purge(self):
     source_a = 'A'
     source_b = 'B'
     manager = ContentCatalogManager()
     for unit_key, url in self.units(0, 10):
         manager.add_entry(source_a, EXPIRATION, TYPE_ID, unit_key, url)
     for unit_key, url in self.units(0, 10):
         manager.add_entry(source_b, EXPIRATION, TYPE_ID, unit_key, url)
     collection = ContentCatalog.get_collection()
     self.assertEqual(20, collection.find().count())
     manager = ContentCatalogManager()
     manager.purge(source_a)
     self.assertEqual(collection.find({'source_id': source_a}).count(), 0)
     self.assertEqual(collection.find({'source_id': source_b}).count(), 10)
Exemplo n.º 3
0
 def test_has_entries(self):
     source_a = 'A'
     source_b = 'B'
     source_c = 'C'
     manager = ContentCatalogManager()
     for unit_key, url in self.units(0, 10):
         manager.add_entry(source_a, EXPIRATION, TYPE_ID, unit_key, url)
     for unit_key, url in self.units(0, 10):
         manager.add_entry(source_b, -1, TYPE_ID, unit_key, url)
     for unit_key, url in self.units(0, 10):
         manager.add_entry(source_c, EXPIRATION, TYPE_ID, unit_key, url)
     collection = ContentCatalog.get_collection()
     self.assertEqual(30, collection.find().count())
     manager = ContentCatalogManager()
     self.assertTrue(manager.has_entries(source_a))
     self.assertFalse(manager.has_entries(source_b))
     self.assertTrue(manager.has_entries(source_c))
     manager.purge(source_c)
     self.assertTrue(manager.has_entries(source_a))
     self.assertFalse(manager.has_entries(source_b))
     self.assertFalse(manager.has_entries(source_c))
Exemplo n.º 4
0
 def test_has_entries(self):
     source_a = 'A'
     source_b = 'B'
     source_c = 'C'
     manager = ContentCatalogManager()
     for unit_key, url in self.units(0, 10):
         manager.add_entry(source_a, EXPIRATION, TYPE_ID, unit_key, url)
     for unit_key, url in self.units(0, 10):
         manager.add_entry(source_b, -1, TYPE_ID, unit_key, url)
     for unit_key, url in self.units(0, 10):
         manager.add_entry(source_c, EXPIRATION, TYPE_ID, unit_key, url)
     collection = ContentCatalog.get_collection()
     self.assertEqual(30, collection.find().count())
     manager = ContentCatalogManager()
     self.assertTrue(manager.has_entries(source_a))
     self.assertFalse(manager.has_entries(source_b))
     self.assertTrue(manager.has_entries(source_c))
     manager.purge(source_c)
     self.assertTrue(manager.has_entries(source_a))
     self.assertFalse(manager.has_entries(source_b))
     self.assertFalse(manager.has_entries(source_c))