本文整理匯總了Python中yum_importer.importer.YumImporter.import_units方法的典型用法代碼示例。如果您正苦於以下問題:Python YumImporter.import_units方法的具體用法?Python YumImporter.import_units怎麽用?Python YumImporter.import_units使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類yum_importer.importer.YumImporter
的用法示例。
在下文中一共展示了YumImporter.import_units方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_distribution_unit_import
# 需要導入模塊: from yum_importer.importer import YumImporter [as 別名]
# 或者: from yum_importer.importer.YumImporter import import_units [as 別名]
def test_distribution_unit_import(self):
existing_units = []
dunit_key = {}
dunit_key['id'] = "ks-TestFamily-TestVariant-16-x86_64"
dunit_key['version'] = "16"
dunit_key['arch'] = "x86_64"
dunit_key['family'] = "TestFamily"
dunit_key['variant'] = "TestVariant"
metadata = { "files" : [{"checksumtype" : "sha256", "relativepath" : "images/fileA.txt", "fileName" : "fileA.txt",
"downloadurl" : "http://repos.fedorapeople.org/repos/pulp/pulp/demo_repos/pulp_unittest//images/fileA.txt",
"item_type" : "tree_file",
"savepath" : "%s/testr1/images" % self.data_dir,
"checksum" : "22603a94360ee24b7034c74fa13d70dd122aa8c4be2010fc1361e1e6b0b410ab",
"filename" : "fileA.txt",
"pkgpath" : "%s/ks-TestFamily-TestVariant-16-x86_64/images" % self.pkg_dir,
"size" : 0 },
{ "checksumtype" : "sha256", "relativepath" : "images/fileB.txt", "fileName" : "fileB.txt",
"downloadurl" : "http://repos.fedorapeople.org/repos/pulp/pulp/demo_repos/pulp_unittest//images/fileB.txt",
"item_type" : "tree_file",
"savepath" : "%s/testr1/images" % self.data_dir,
"checksum" : "8dc89e9883c098443f6616e60a8e489254bf239eeade6e4b4943b7c8c0c345a4",
"filename" : "fileB.txt",
"pkgpath" : "%s/ks-TestFamily-TestVariant-16-x86_64/images" % self.pkg_dir, "size" : 0 },
{ "checksumtype" : "sha256", "relativepath" : "images/fileC.iso", "fileName" : "fileC.iso",
"downloadurl" : "http://repos.fedorapeople.org/repos/pulp/pulp/demo_repos/pulp_unittest//images/fileC.iso",
"item_type" : "tree_file",
"savepath" : "%s/testr1/images" % self.data_dir,
"checksum" : "099f2bafd533e97dcfee778bc24138c40f114323785ac1987a0db66e07086f74",
"filename" : "fileC.iso",
"pkgpath" : "%s/ks-TestFamily-TestVariant-16-x86_64/images" % self.pkg_dir, "size" : 0 } ],}
distro_unit = [Unit(TYPE_ID_DISTRO, dunit_key, metadata, '')]
distro_unit[0].storage_path = "%s/ks-TestFamily-TestVariant-16-x86_64" % self.pkg_dir
existing_units += distro_unit
# REPO A (source)
repoA = mock.Mock(spec=Repository)
repoA.working_dir = self.data_dir
repoA.id = "test_distro_unit_copy"
# REPO B (target)
repoB = mock.Mock(spec=Repository)
repoB.working_dir = self.working_dir
repoB.id = "repoB"
conduit = importer_mocks.get_import_conduit([distro_unit], existing_units=existing_units)
config = importer_mocks.get_basic_config()
importer = YumImporter()
# Test
result = importer.import_units(repoA, repoB, conduit, config, distro_unit)
# Verify
print conduit.associate_unit.call_args_list
associated_units = [mock_call[0][0] for mock_call in conduit.associate_unit.call_args_list]
self.assertEqual(len(associated_units), len(distro_unit))
for u in associated_units:
self.assertTrue(u in distro_unit)
示例2: test_import
# 需要導入模塊: from yum_importer.importer import YumImporter [as 別名]
# 或者: from yum_importer.importer.YumImporter import import_units [as 別名]
def test_import(self):
# Setup
existing_units = self.existing_units()
# REPO A (source)
repoA = mock.Mock(spec=Repository)
repoA.working_dir = self.data_dir
repoA.id = "test_resolve_deps"
# REPO B (target)
repoB = mock.Mock(spec=Repository)
repoB.working_dir = self.working_dir
repoB.id = "repoB"
units = [Unit(TYPE_ID_RPM, self.UNIT_KEY_B, {}, '')]
conduit = importer_mocks.get_import_conduit(units, existing_units=existing_units)
config = importer_mocks.get_basic_config()
importer = YumImporter()
# Test
result = importer.import_units(repoA, repoB, conduit, config, units)
# Verify
associated_units = [mock_call[0][0] for mock_call in conduit.associate_unit.call_args_list]
self.assertEqual(len(associated_units), len(units))
for u in associated_units:
self.assertTrue(u in units)
示例3: test_package_category_unit_import
# 需要導入模塊: from yum_importer.importer import YumImporter [as 別名]
# 或者: from yum_importer.importer.YumImporter import import_units [as 別名]
def test_package_category_unit_import(self):
# REPO A (source)
repoA = mock.Mock(spec=Repository)
repoA.working_dir = self.data_dir
repoA.id = "test_pkg_cat_unit_copy"
# REPO B (target)
repoB = mock.Mock(spec=Repository)
repoB.working_dir = self.working_dir
repoB.id = "repoB"
# Create 2 pkg groups
grp_a = self.create_dummy_pkg_group_unit(repoA.id, "group_a")
# Create 2 pkg categories
cat_a = self.create_dummy_pkg_category_unit(repoA.id, "cat_a", ["group_a"])
# Add the grps/cats to the publish_conduit
existing_units=[grp_a, cat_a]
conduit = importer_mocks.get_import_conduit([cat_a], existing_units=existing_units)
config = importer_mocks.get_basic_config()
importer = YumImporter()
# Test
result = importer.import_units(repoA, repoB, conduit, config, [cat_a])
# Verify
associated_units = [mock_call[0][0] for mock_call in conduit.associate_unit.call_args_list]
for u in associated_units:
self.assertTrue(u in [cat_a, grp_a])
示例4: test_import_with_dependencies
# 需要導入模塊: from yum_importer.importer import YumImporter [as 別名]
# 或者: from yum_importer.importer.YumImporter import import_units [as 別名]
def test_import_with_dependencies(self):
# Setup
existing_units = self.existing_units()
# REPO A (source)
repoA = mock.Mock(spec=Repository)
repoA.working_dir = "/tmp/test_resolve_deps"
repoA.id = "test_resolve_deps"
# REPO B (target)
repoB = mock.Mock(spec=Repository)
repoB.working_dir = "/tmp/test_resolve_deps"
repoB.id = "repo_b"
units = [Unit(TYPE_ID_RPM, self.UNIT_KEY_B, {}, '')]
conduit = importer_mocks.get_import_conduit(units, existing_units=existing_units)
config = importer_mocks.get_basic_config()
config.override_config['recursive'] = True
config.override_config['resolve_dependencies'] = True
importer = YumImporter()
# Test
result = importer.import_units(repoA, repoB, conduit, config, units)
# Verify
associated_units = [mock_call[0][0] for mock_call in conduit.associate_unit.call_args_list]
self.assertEqual(len(associated_units), len(existing_units))
for u in associated_units:
self.assertTrue(u in existing_units + units)
示例5: test_package_group_unit_import
# 需要導入模塊: from yum_importer.importer import YumImporter [as 別名]
# 或者: from yum_importer.importer.YumImporter import import_units [as 別名]
#.........這裏部分代碼省略.........
'name':'pulp-dot-1.0-test',
'version':'0.1.1',
'release':'1.fc11',
'epoch':'0',
'arch':'x86_64',
'checksum':'435d92e6c09248b501b8d2ae786f92ccfad69fab8b1bc774e2b66ff6c0d83979',
'checksumtype':'sha256',
}
metadata = {
'filename':filename
}
u = Unit(TYPE_ID_RPM, unit_key, metadata, storage_path)
source_units.append(u)
verify_units.append(u)
storage_path = '%s/pulp-dot-2.0-test/0.1.2/1.fc11/x86_64/435d92e6c09248b501b8d2ae786f92ccfad69fab8b1bc774e2b66ff6c0d83979/pulp-dot-2.0-test-0.1.2-1.fc11.x86_64.rpm' % (self.pkg_dir)
filename = os.path.basename(storage_path)
unit_key = {
'name':'pulp-dot-2.0-test',
'version':'0.1.2',
'release':'1.fc11',
'epoch':'0',
'arch':'x86_64',
'checksum':'435d92e6c09248b501b8d2ae786f92ccfad69fab8b1bc774e2b66ff6c0d83979',
'checksumtype':'sha256',
}
metadata = {
'filename':filename
}
u = Unit(TYPE_ID_RPM, unit_key, metadata, storage_path)
source_units.append(u)
verify_units.append(u)
storage_path = '%s/pulp-test-package/0.3.1/1.fc11/x86_64/6bce3f26e1fc0fc52ac996f39c0d0e14fc26fb8077081d5b4dbfb6431b08aa9f/pulp-test-package-0.3.1-1.fc11.x86_64.rpm' % (self.pkg_dir)
filename = os.path.basename(storage_path)
unit_key = {
'name':'pulp-test-package',
'version':'0.3.1',
'release':'1.fc11',
'epoch':'0',
'arch':'x86_64',
'checksum':'6bce3f26e1fc0fc52ac996f39c0d0e14fc26fb8077081d5b4dbfb6431b08aa9f',
'checksumtype':'sha256',
}
metadata = {
'filename':filename
}
u = Unit(TYPE_ID_RPM, unit_key, metadata, storage_path)
source_units.append(u)
verify_old_version_skipped = [u]
storage_path = '%s/pulp-test-package/0.3.2/1.fc11/x86_64/6bce3f26e1fc0fc52ac996f39c0d0e14fc26fb8077081d5b4dbfb6431b08aa9f/pulp-test-package-0.3.1-1.fc11.x86_64.rpm' % (self.pkg_dir)
filename = os.path.basename(storage_path)
unit_key = {
'name':'pulp-test-package',
'version':'0.3.2',
'release':'1.fc11',
'epoch':'0',
'arch':'x86_64',
'checksum':'6bce3f26e1fc0fc52ac996f39c0d0e14fc26fb8077081d5b4dbfb6431b08aa9f',
'checksumtype':'sha256',
}
metadata = {
'filename':filename
}
u = Unit(TYPE_ID_RPM, unit_key, metadata, storage_path)
source_units.append(u)
verify_units.append(u)
storage_path = '%s/pulp-test-optional-package/0.3.2/1.fc11/x86_64/6bce3f26e1fc0fc52ac996f39c0d0e14fc26fb8077081d5b4dbfb6431b08aa9f/pulp-test-package-0.3.1-1.fc11.x86_64.rpm' % (self.pkg_dir)
filename = os.path.basename(storage_path)
unit_key = {
'name':'pulp-optional-package',
'version':'0.1.1',
'release':'1.fc11',
'epoch':'0',
'arch':'x86_64',
'checksum':'6bce3f26e1fc0fc52ac996f39c0d0e14fc26fb8077081d5b4dbfb6431b08aa9f',
'checksumtype':'sha256',
}
metadata = {
'filename':filename
}
u = Unit(TYPE_ID_RPM, unit_key, metadata, storage_path)
source_units.append(u)
verify_units.append(u)
grp_a.metadata['mandatory_package_names'] = ["pulp-test-package",]
grp_a.metadata['default_package_names'] = ["pulp-dot-2.0-test"]
grp_a.metadata['optional_package_names'] = ["pulp-optional-package"]
grp_a.metadata['conditional_package_names'] = [('pulp-dot-1.0-test', [])]
existing_units = [grp_a]
conduit = importer_mocks.get_import_conduit(source_units + [grp_a], existing_units=source_units + existing_units)
config = importer_mocks.get_basic_config()
importer = YumImporter()
# Test
result = importer.import_units(repoA, repoB, conduit, config, [grp_a])
# Verify
associated_units = [mock_call[0][0] for mock_call in conduit.associate_unit.call_args_list]
# verify expected units are in associate units
for u in verify_units:
self.assertTrue(u in associated_units)
# verify that the version compare worked and skipped old versions
for u in verify_old_version_skipped:
self.assertFalse(u in associated_units)
示例6: test_errata_import_units
# 需要導入模塊: from yum_importer.importer import YumImporter [as 別名]
# 或者: from yum_importer.importer.YumImporter import import_units [as 別名]
def test_errata_import_units(self):
existing_units = []
unit_key = dict()
unit_key['id'] = "RHEA-2010:9999"
mdata = { 'description' : "test",
'from_str': '[email protected]',
'issued': '2010-03-30 08:07:30',
'pkglist': [{'name': 'RHEL Virtualization (v. 5 for 32-bit x86)',
'packages': [{'arch': 'x86_64',
'epoch': '0',
'filename': 'patb-0.1-2.x86_64.rpm',
'name': 'patb',
'release': '2',
'src': '',
'sum': ('sha',
'017c12050a97cf6095892498750c2a39d2bf535e'),
'version': '0.1'},
{'arch': 'x86_64',
'epoch': '0',
'filename': 'emoticons-0.1-2.x86_64.rpm',
'name': 'emoticons',
'release': '2',
'src': '',
'sum': ('sha',
'663c89b0d29bfd5479d8736b716d50eed9495dbb'),
'version': '0.1'}],
'short': 'rhel-i386-server-vt-5'}],
'pushcount': 1,
'reboot_suggested': False,
'references': [],
'release': '',
'rights': '',
'status': 'final',
'summary': '',
'title': 'emoticons enhancement fix and enhancement update',
'updated': '2010-03-30 08:07:30',
'version': '1',
'type' : 'enhancement',
'severity' : 'Low',
'solution' : ''}
unit_key_2 = dict()
unit_key_2['id'] = "RHEA-2008:9999"
mdata_2 = { 'description' : "test",
'from_str': '[email protected]',
'issued': '2008-03-30 00:00:00',
'pkglist': [{'name': 'RHEL Virtualization (v. 5 for 32-bit x86)',
'packages': [{'arch': 'x86_64',
'epoch': '0',
'filename': 'patb-0.1-2.x86_64.rpm',
'name': 'patb',
'release': '2',
'src': '',
'sum': ('sha',
'017c12050a97cf6095892498750c2a39d2bf535e'),
'version': '0.1'},
{'arch': 'x86_64',
'epoch': '0',
'filename': 'emoticons-0.1-2.x86_64.rpm',
'name': 'emoticons',
'release': '2',
'src': '',
'sum': ('sha',
'663c89b0d29bfd5479d8736b716d50eed9495dbb'),
'version': '0.1'}],
'short': 'rhel-i386-server-vt-5'}],
'pushcount': 1,
'reboot_suggested': False,
'references': [],
'release': '',
'rights': '',
'status': 'final',
'summary': '',
'title': 'emoticons enhancement fix and enhancement update',
'updated': '2008-03-30 00:00:00',
'version': '1',
'type' : 'enhancement',
'severity' : 'Low',
'solution' : ''}
errata_unit = [Unit(TYPE_ID_ERRATA, unit_key, mdata, ''), Unit(TYPE_ID_ERRATA, unit_key_2, mdata_2, '')]
existing_units += errata_unit
# REPO A (source)
repoA = mock.Mock(spec=Repository)
repoA.working_dir = self.data_dir
repoA.id = "test_errata_unit_copy"
# REPO B (target)
repoB = mock.Mock(spec=Repository)
repoB.working_dir = self.working_dir
repoB.id = "repoB"
conduit = importer_mocks.get_import_conduit(errata_unit, existing_units=existing_units)
config = importer_mocks.get_basic_config(blacklist=['patb'])
importer = YumImporter()
# Test
result = importer.import_units(repoA, repoB, conduit, config, errata_unit)
# Verify
associated_units = [mock_call[0][0] for mock_call in conduit.associate_unit.call_args_list]
self.assertEqual(len(associated_units), len(errata_unit))
for u in associated_units:
self.assertTrue(u in errata_unit)