当前位置: 首页>>代码示例>>Python>>正文


Python ContentCatalog.get_locator方法代码示例

本文整理汇总了Python中pulp.server.db.model.content.ContentCatalog.get_locator方法的典型用法代码示例。如果您正苦于以下问题:Python ContentCatalog.get_locator方法的具体用法?Python ContentCatalog.get_locator怎么用?Python ContentCatalog.get_locator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pulp.server.db.model.content.ContentCatalog的用法示例。


在下文中一共展示了ContentCatalog.get_locator方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_locator

# 需要导入模块: from pulp.server.db.model.content import ContentCatalog [as 别名]
# 或者: from pulp.server.db.model.content.ContentCatalog import get_locator [as 别名]
 def test_locator(self):
     key_1 = {'a': 1, 'b': 2, 'c': 3}
     key_2 = {'c': 3, 'b': 2, 'a': 1}
     key_3 = {'c': 1, 'b': 2, 'a': 3}
     locator_1 = ContentCatalog.get_locator(TYPE_ID, key_1)  # eq
     locator_2 = ContentCatalog.get_locator(TYPE_ID, key_2)  # eq
     locator_3 = ContentCatalog.get_locator(TYPE_ID, key_3)  # neq
     locator_4 = ContentCatalog.get_locator(TYPE_ID[1:], key_1)  # neq
     self.assertTrue(isinstance(locator_1, str))
     self.assertTrue(isinstance(locator_2, str))
     self.assertEqual(locator_1, locator_2)
     self.assertNotEqual(locator_1, locator_3)
     self.assertNotEqual(locator_1, locator_4)
开发者ID:ashcrow,项目名称:pulp,代码行数:15,代码来源:test_content_catalog_manager.py

示例2: test_add

# 需要导入模块: from pulp.server.db.model.content import ContentCatalog [as 别名]
# 或者: from pulp.server.db.model.content.ContentCatalog import get_locator [as 别名]
 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)
开发者ID:ashcrow,项目名称:pulp,代码行数:15,代码来源:test_content_catalog_manager.py

示例3: delete_entry

# 需要导入模块: from pulp.server.db.model.content import ContentCatalog [as 别名]
# 或者: from pulp.server.db.model.content.ContentCatalog import get_locator [as 别名]
 def delete_entry(self, source_id, type_id, unit_key):
     """
     Delete an entry from the content catalog.
     :param source_id: A content source ID.
     :type source_id: str
     :param type_id: The unit type ID.
     :type type_id: str
     :param unit_key: The unit key.
     :type unit_key: dict
     """
     collection = ContentCatalog.get_collection()
     locator = ContentCatalog.get_locator(type_id, unit_key)
     query = {'source_id': source_id, 'locator': locator}
     collection.remove(query, safe=True)
开发者ID:CUXIDUMDUM,项目名称:pulp,代码行数:16,代码来源:catalog.py

示例4: test_add

# 需要导入模块: from pulp.server.db.model.content import ContentCatalog [as 别名]
# 或者: from pulp.server.db.model.content.ContentCatalog import get_locator [as 别名]
 def test_add(self):
     units = self.units(0, 10)
     conduit = CatalogerConduit(SOURCE_ID, EXPIRES)
     for unit_key, url in units:
         conduit.add_entry(TYPE_ID, unit_key, url)
     collection = ContentCatalog.get_collection()
     self.assertEqual(conduit.source_id, SOURCE_ID)
     self.assertEqual(conduit.expires, EXPIRES)
     self.assertEqual(len(units), collection.find().count())
     self.assertEqual(conduit.added_count, len(units))
     self.assertEqual(conduit.deleted_count, 0)
     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)
开发者ID:lzap,项目名称:pulp,代码行数:19,代码来源:test_cataloger_conduit.py

示例5: test_delete

# 需要导入模块: from pulp.server.db.model.content import ContentCatalog [as 别名]
# 或者: from pulp.server.db.model.content.ContentCatalog import get_locator [as 别名]
 def test_delete(self):
     units = self.units(0, 10)
     conduit = CatalogerConduit(SOURCE_ID, EXPIRES)
     for unit_key, url in units:
         conduit.add_entry(TYPE_ID, unit_key, url)
     collection = ContentCatalog.get_collection()
     self.assertEqual(len(units), collection.find().count())
     unit_key, url = units[5]
     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)
     conduit.delete_entry(TYPE_ID, unit_key)
     self.assertEqual(len(units) - 1, collection.find().count())
     self.assertEqual(conduit.added_count, len(units))
     self.assertEqual(conduit.deleted_count, 1)
     entry = collection.find_one({"locator": locator})
     self.assertTrue(entry is None)
开发者ID:lzap,项目名称:pulp,代码行数:21,代码来源:test_cataloger_conduit.py

示例6: find

# 需要导入模块: from pulp.server.db.model.content import ContentCatalog [as 别名]
# 或者: from pulp.server.db.model.content.ContentCatalog import get_locator [as 别名]
 def find(self, type_id, unit_key):
     """
     Find entries in the content catalog using the specified unit type_id
     and unit_key.  The catalog may contain more than one entry matching the
     locator for a given content source.  In this case, only the newest entry
     for each source is included in the result set.
     :param type_id: The unit type ID.
     :type type_id: str
     :param unit_key: The unit key.
     :type unit_key: dict
     :return: A list of matching entries.
     :rtype: list
     """
     collection = ContentCatalog.get_collection()
     locator = ContentCatalog.get_locator(type_id, unit_key)
     query = {
         'locator': locator,
         'expiration': {'$gte': ContentCatalog.get_expiration(0)}
     }
     newest_by_source = {}
     for entry in collection.find(query, sort=[('_id', ASCENDING)]):
         newest_by_source[entry['source_id']] = entry
     return newest_by_source.values()
开发者ID:CUXIDUMDUM,项目名称:pulp,代码行数:25,代码来源:catalog.py


注:本文中的pulp.server.db.model.content.ContentCatalog.get_locator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。