本文整理匯總了Python中yum_importer.importer.YumImporter._upload_unit方法的典型用法代碼示例。如果您正苦於以下問題:Python YumImporter._upload_unit方法的具體用法?Python YumImporter._upload_unit怎麽用?Python YumImporter._upload_unit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類yum_importer.importer.YumImporter
的用法示例。
在下文中一共展示了YumImporter._upload_unit方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_upload_rpm
# 需要導入模塊: from yum_importer.importer import YumImporter [as 別名]
# 或者: from yum_importer.importer.YumImporter import _upload_unit [as 別名]
def test_upload_rpm(self):
repo = mock.Mock(spec=Repository)
repo.working_dir = self.working_dir
repo.id = "test_upload_rpm"
upload_conduit = importer_mocks.get_upload_conduit(pkg_dir=self.pkg_dir)
config = importer_mocks.get_basic_config()
importer = YumImporter()
file_path = "%s/%s" % (self.data_dir, "incisura-7.1.4-1.elfake.noarch.rpm")
mdata = {'filename' : "incisura-7.1.4-1.elfake.noarch.rpm", 'checksum' : 'e0e98e76e4e06dad65a82b0111651d7aca5b00fe'}
unit_key = {'name' : 'incisura', 'version' : '7.1.4', 'release' : '1', 'arch' : 'noarch', 'checksum' : 'e0e98e76e4e06dad65a82b0111651d7aca5b00fe', 'checksumtype' : 'sha1'}
type_id = "rpm"
status, summary, details = importer._upload_unit(repo, type_id, unit_key, mdata, file_path, upload_conduit, config)
self.assertTrue(status)
self.assertTrue(summary is not None)
self.assertTrue(details is not None)
# validate if metadata was generated
self.assertTrue(mdata.has_key('repodata'))
self.assertTrue(mdata['repodata']['primary'] is not None)
self.assertTrue(mdata['repodata']['other'] is not None)
self.assertTrue(mdata['repodata']['filelists'] is not None)
primary_snippet = mdata['repodata']['primary']
location_start_index = primary_snippet.find("href=")
# verify the location matches the basename of the package
self.assertTrue(primary_snippet[location_start_index:location_start_index + len("href=") + len("incisura-7.1.4-1.elfake.noarch.rpm") + 2 ] ==
"href=\"incisura-7.1.4-1.elfake.noarch.rpm\"")
self.assertEquals(summary["num_units_saved"], 1)
self.assertEquals(summary["num_units_processed"], 1)
self.assertEquals(summary["filename"], "incisura-7.1.4-1.elfake.noarch.rpm")
self.assertEquals(details["errors"], [])
示例2: test_upload_package_group
# 需要導入模塊: from yum_importer.importer import YumImporter [as 別名]
# 或者: from yum_importer.importer.YumImporter import _upload_unit [as 別名]
def test_upload_package_group(self):
repo = mock.Mock(spec=Repository)
repo.working_dir = self.working_dir
repo.id = "test_upload_package_group"
upload_conduit = importer_mocks.get_upload_conduit(pkg_dir=self.pkg_dir)
config = importer_mocks.get_basic_config()
importer = YumImporter()
file_path = None
type_id = TYPE_ID_PKG_CATEGORY
unit = self.get_pkg_group_or_category(repo, type_id)
status, summary, details = importer._upload_unit(repo, type_id, unit.unit_key, unit.metadata, file_path, upload_conduit, config)
self.assertTrue(status)
self.assertEqual(summary['state'], 'FINISHED')
示例3: test_upload_erratum
# 需要導入模塊: from yum_importer.importer import YumImporter [as 別名]
# 或者: from yum_importer.importer.YumImporter import _upload_unit [as 別名]
def test_upload_erratum(self):
repo = mock.Mock(spec=Repository)
repo.working_dir = self.working_dir
repo.id = "test_upload_errata"
upload_conduit = importer_mocks.get_upload_conduit(pkg_dir=self.pkg_dir)
config = importer_mocks.get_basic_config()
importer = YumImporter()
file_path = []
type_id = "erratum"
unit_key = dict()
unit_key['id'] = "RHBA-2012:0101"
metadata = {"pkglist" : [],}
status, summary, details = importer._upload_unit(repo, type_id, unit_key, metadata, file_path, upload_conduit, config)
self.assertTrue(status)
self.assertEqual(summary['state'], 'FINISHED')
示例4: test_upload_rpm
# 需要導入模塊: from yum_importer.importer import YumImporter [as 別名]
# 或者: from yum_importer.importer.YumImporter import _upload_unit [as 別名]
def test_upload_rpm(self):
repo = mock.Mock(spec=Repository)
repo.working_dir = self.working_dir
repo.id = "test_upload_rpm"
upload_conduit = importer_mocks.get_upload_conduit(pkg_dir=self.pkg_dir)
config = importer_mocks.get_basic_config()
importer = YumImporter()
file_path = "%s/%s" % (self.data_dir, "incisura-7.1.4-1.elfake.noarch.rpm")
metadata = {'filename' : "incisura-7.1.4-1.elfake.noarch.rpm", 'checksum' : 'e0e98e76e4e06dad65a82b0111651d7aca5b00fe'}
unit_key = {'name' : 'incisura', 'version' : '7.1.4', 'release' : '1', 'arch' : 'noarch', 'checksum' : 'e0e98e76e4e06dad65a82b0111651d7aca5b00fe', 'checksumtype' : 'sha1'}
type_id = "rpm"
status, summary, details = importer._upload_unit(repo, type_id, unit_key, metadata, file_path, upload_conduit, config)
self.assertTrue(status)
self.assertTrue(summary is not None)
self.assertTrue(details is not None)
self.assertEquals(summary["num_units_saved"], 1)
self.assertEquals(summary["num_units_processed"], 1)
self.assertEquals(summary["filename"], "incisura-7.1.4-1.elfake.noarch.rpm")
self.assertEquals(details["errors"], [])