Exemplo n.º 1
0
 def test_add(self):
     units = self.units(0, 10)
     manager = ContentCatalogManager()
     for unit_key, url in units:
         manager.add_entry(SOURCE_ID, EXPIRATION, TYPE_ID, unit_key, url)
     collection = ContentCatalog.get_collection()
     self.assertEqual(len(units), collection.find().count())
     for unit_key, url in units:
         locator = ContentCatalog.get_locator(TYPE_ID, unit_key)
         entry = collection.find_one({'locator': locator})
         self.assertEqual(entry['type_id'], TYPE_ID)
         self.assertEqual(entry['unit_key'], unit_key)
         self.assertEqual(entry['url'], url)
Exemplo n.º 2
0
 def test_add(self):
     units = self.units(0, 10)
     manager = ContentCatalogManager()
     for unit_key, url in units:
         manager.add_entry(SOURCE_ID, EXPIRATION, TYPE_ID, unit_key, url)
     collection = ContentCatalog.get_collection()
     self.assertEqual(len(units), collection.find().count())
     for unit_key, url in units:
         locator = ContentCatalog.get_locator(TYPE_ID, unit_key)
         entry = collection.find_one({'locator': locator})
         self.assertEqual(entry['type_id'], TYPE_ID)
         self.assertEqual(entry['unit_key'], unit_key)
         self.assertEqual(entry['url'], url)
Exemplo n.º 3
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.º 4
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.º 5
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.º 6
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))