本文整理汇总了Python中pulp.plugins.types.database.update_database函数的典型用法代码示例。如果您正苦于以下问题:Python update_database函数的具体用法?Python update_database怎么用?Python update_database使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了update_database函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_update_no_changes
def test_update_no_changes(self):
"""
Tests the common use case of loading type definitions that have been
loaded already and have not changed.
"""
# Setup
defs = [DEF_1, DEF_2, DEF_3, DEF_4]
types_db.update_database(defs)
# Test
same_defs = [DEF_4, DEF_3, DEF_2, DEF_1] # no real reason for this, just felt better than using the previous list
types_db.update_database(same_defs)
# Verify
all_collection_names = types_db.all_type_collection_names()
self.assertEqual(len(same_defs), len(all_collection_names))
for d in defs:
self.assertTrue(types_db.unit_collection_name(d.id) in all_collection_names)
# Quick sanity check on the indexes
collection = types_db.type_units_collection(d.id)
all_indexes = collection.index_information()
total_index_count = 1 + 1 + len(d.search_indexes) # _id + unit key + all search
self.assertEqual(total_index_count, len(all_indexes))
示例2: test_update_missing_no_error
def test_update_missing_no_error(self):
"""
Tests that updating a previously loaded database with some missing
definitions does not throw an error.
"""
# Setup
defs = [DEF_1, DEF_2, DEF_3]
types_db.update_database(defs)
# Test
new_defs = [DEF_4]
types_db.update_database(new_defs)
# Verify
all_collection_names = types_db.all_type_collection_names()
self.assertEqual(len(defs) + len(new_defs), len(all_collection_names)) # old are not deleted
for d in defs:
self.assertTrue(types_db.unit_collection_name(d.id) in all_collection_names)
# Quick sanity check on the indexes
collection = types_db.type_units_collection(d.id)
all_indexes = collection.index_information()
total_index_count = 1 + 1 + len(d.search_indexes) # _id + unit key + all search
self.assertEqual(total_index_count, len(all_indexes))
示例3: init_types
def init_types(self):
database.clean()
fp = open(self.TYPES_PATH)
td = TypeDescriptor(os.path.basename(self.TYPES_PATH), fp.read())
fp.close()
definitions = parser.parse([td])
database.update_database(definitions)
示例4: setUp
def setUp(self):
super(RepoUnitAssociationManagerTests, self).setUp()
database.update_database([TYPE_1_DEF, TYPE_2_DEF, MOCK_TYPE_DEF])
mock_plugins.install()
self.manager = association_manager.RepoUnitAssociationManager()
self.repo_manager = repo_manager.RepoManager()
self.importer_manager = importer_manager.RepoImporterManager()
self.content_manager = content_cud_manager.ContentManager()
# Set up a valid configured repo for the tests
self.repo_id = 'associate-repo'
self.repo_manager.create_repo(self.repo_id)
self.importer_manager.set_importer(self.repo_id, 'mock-importer', {})
# Create units that can be associated to a repo
self.unit_type_id = 'mock-type'
self.unit_id = 'test-unit-id'
self.unit_key = {'key-1': 'test-unit'}
self.content_manager.add_content_unit(self.unit_type_id, self.unit_id, self.unit_key)
self.unit_id_2 = 'test-unit-id-2'
self.unit_key_2 = {'key-1': 'test-unit-2'}
self.content_manager.add_content_unit(self.unit_type_id, self.unit_id_2, self.unit_key_2)
示例5: setUp
def setUp(self):
super(UnitAssociationQueryTests, self).setUp()
database.update_database(_QUERY_TYPES)
self.manager = association_query_manager.RepoUnitAssociationQueryManager()
self.association_manager = association_manager.RepoUnitAssociationManager()
self.content_manager = content_cud_manager.ContentManager()
self._populate()
示例6: setUp
def setUp(self):
super(Migration0004Tests, self).setUp()
# Special way to import modules that start with a number
self.migration = _import_all_the_way(
'pulp_rpm.plugins.migrations.0004_pkg_group_category_repoid')
factory.initialize()
api.initialize(False)
types_db.update_database([TYPE_DEF_GROUP, TYPE_DEF_CATEGORY])
# Create the repositories necessary for the tests
self.source_repo_id = 'source-repo' # where units were copied from with the bad code
self.dest_repo_id = 'dest-repo' # where bad units were copied to
source_repo = model.Repository(repo_id=self.source_repo_id)
source_repo.save()
dest_repo = model.Repository(repo_id=self.dest_repo_id)
dest_repo.save()
source_importer = model.Importer(self.source_repo_id, 'yum_importer', {})
source_importer.save()
dest_importer = model.Importer(self.dest_repo_id, 'yum_importer', {})
dest_importer.save()
示例7: setUp
def setUp(self):
super(Migration0004Tests, self).setUp()
# Special way to import modules that start with a number
self.migration = _import_all_the_way(
'pulp_rpm.plugins.migrations.0004_pkg_group_category_repoid')
factory.initialize()
types_db.update_database([TYPE_DEF_GROUP, TYPE_DEF_CATEGORY])
# Create the repositories necessary for the tests
self.source_repo_id = 'source-repo' # where units were copied from with the bad code
self.dest_repo_id = 'dest-repo' # where bad units were copied to
source_repo = Repo(self.source_repo_id, '')
Repo.get_collection().insert(source_repo, safe=True)
dest_repo = Repo(self.dest_repo_id, '')
Repo.get_collection().insert(dest_repo, safe=True)
source_importer = RepoImporter(self.source_repo_id, 'yum_importer', 'yum_importer', {})
RepoImporter.get_collection().insert(source_importer, safe=True)
dest_importer = RepoImporter(self.dest_repo_id, 'yum_importer', 'yum_importer', {})
RepoImporter.get_collection().insert(dest_importer, safe=True)
示例8: load_content_types
def load_content_types(types_dir=_TYPES_DIR, dry_run=False, drop_indices=False):
"""
Check or update database with content unit types information.
:param types_dir: path to content unit type JSON files,
currently used only for node.json
:type types_dir: str
:param dry_run: if True, no modifications to database will be made, defaults to False
:type dry_run: bool
:param drop_indices: if True, indices for the collections of modified unit types
will be dropped, defaults to False
:type drop_indices: bool
:return: None if dry_run is set to False,
list of content unit types to be created or updated, if dry_run is set to True
:rtype: None or list of TypeDefinition
"""
if not os.access(types_dir, os.F_OK | os.R_OK):
msg = _('Cannot load types: path does not exist or cannot be read: %(p)s')
_logger.critical(msg % {'p': types_dir})
raise IOError(msg % {'p': types_dir})
# to handle node.json only
descriptors = _load_type_descriptors(types_dir)
pre_mongoengine_definitions = parser.parse(descriptors)
# get information about content unit types from entry points
mongoengine_definitions = _generate_plugin_definitions()
if dry_run:
return _check_content_definitions(pre_mongoengine_definitions + mongoengine_definitions)
else:
database.update_database(pre_mongoengine_definitions, drop_indices=drop_indices,
create_indexes=True)
database.update_database(mongoengine_definitions, drop_indices=drop_indices,
create_indexes=False)
示例9: setUp
def setUp(self):
super(UnitAssociationQueryTests, self).setUp()
database.update_database(_QUERY_TYPES)
self.manager = association_query_manager.RepoUnitAssociationQueryManager()
self.association_manager = association_manager.RepoUnitAssociationManager()
self.content_manager = content_cud_manager.ContentManager()
# so we don't try to refresh the unit count on non-existing repos
manager_factory._CLASSES[manager_factory.TYPE_REPO] = mock.MagicMock()
self._populate()
示例10: setUp
def setUp(self):
super(BaseProfilerConduitTests, self).setUp()
Consumer.get_collection().remove()
RepoDistributor.get_collection().remove()
Bind.get_collection().remove()
RepoContentUnit.get_collection().remove()
UnitProfile.get_collection().remove()
plugin_api._create_manager()
typedb.update_database([self.TYPE_1_DEF, self.TYPE_2_DEF])
mock_plugins.install()
示例11: setUp
def setUp(self):
super(RepoUnitAssociationManagerTests, self).setUp()
database.update_database([TYPE_1_DEF, TYPE_2_DEF, MOCK_TYPE_DEF])
mock_plugins.install()
# so we don't try to refresh the unit count on non-existing repos
manager_factory._CLASSES[manager_factory.TYPE_REPO] = mock.MagicMock()
self.manager = association_manager.RepoUnitAssociationManager()
self.repo_manager = repo_manager.RepoManager()
self.importer_manager = importer_manager.RepoImporterManager()
self.content_manager = content_cud_manager.ContentManager()
示例12: setUp
def setUp(self, mock_repo_qs, mock_imp_qs, mock_remove):
super(RepoSyncConduitTests, self).setUp()
mock_plugins.install()
types_database.update_database([TYPE_1_DEF, TYPE_2_DEF])
self.association_manager = association_manager.RepoUnitAssociationManager()
self.association_query_manager = association_query_manager.RepoUnitAssociationQueryManager()
self.content_manager = content_manager.ContentManager()
self.query_manager = query_manager.ContentQueryManager()
self.conduit = RepoSyncConduit('repo-1', 'test-importer', 'abc123')
importer_controller.set_importer('repo-1', 'mock-importer', {})
示例13: setUp
def setUp(self):
super(DependencyManagerTests, self).setUp()
mock_plugins.install()
database.update_database([TYPE_1_DEF])
self.repo_id = 'dep-repo'
self.manager = manager_factory.dependency_manager()
manager_factory.repo_manager().create_repo(self.repo_id)
manager_factory.repo_importer_manager().set_importer(self.repo_id, 'mock-importer', {})
示例14: test_all_type_definitions
def test_all_type_definitions(self):
"""
Tests retrieving all type definitions from the database.
"""
# Setup
defs = [DEF_1, DEF_2, DEF_3, DEF_4]
types_db.update_database(defs)
# Test
all_defs = types_db.all_type_definitions()
# Verify
self.assertEqual(4, len(all_defs))
示例15: setUp
def setUp(self):
super(RepoSyncConduitTests, self).setUp()
mock_plugins.install()
types_database.update_database([TYPE_1_DEF, TYPE_2_DEF])
self.repo_manager = repo_manager.RepoManager()
self.importer_manager = importer_manager.RepoImporterManager()
self.sync_manager = sync_manager.RepoSyncManager()
self.association_manager = association_manager.RepoUnitAssociationManager()
self.association_query_manager = association_query_manager.RepoUnitAssociationQueryManager()
self.content_manager = content_manager.ContentManager()
self.query_manager = query_manager.ContentQueryManager()
self.repo_manager.create_repo('repo-1')
self.conduit = RepoSyncConduit('repo-1', 'test-importer', 'importer', 'importer-id')