本文整理汇总了Python中model_factory.rpm_models函数的典型用法代码示例。如果您正苦于以下问题:Python rpm_models函数的具体用法?Python rpm_models怎么用?Python rpm_models使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rpm_models函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
super(TestRemoveOldVersions, self).setUp()
self.rpms = model_factory.rpm_models(3, True)
self.rpms.extend(model_factory.rpm_models(2, False))
self.srpms = model_factory.srpm_models(3, True)
self.srpms.extend(model_factory.srpm_models(2, False))
self.drpms = model_factory.drpm_models(3, True)
self.drpms.extend(model_factory.drpm_models(2, False))
示例2: test_rpms_check_all_and_associate_negative
def test_rpms_check_all_and_associate_negative(self, mock_isfile, mock_save, mock_search_all_units):
mock_search_all_units.return_value = []
mock_isfile.return_value = True
units = model_factory.rpm_models(3)
input_units = set([unit.as_named_tuple for unit in units])
result = check_all_and_associate(input_units, self.conduit)
self.assertEqual(len(list(result)), 3)
示例3: test_associate_already_downloaded_units_negative
def test_associate_already_downloaded_units_negative(self, mock_save, mock_search_all_units):
mock_search_all_units.return_value = []
units = model_factory.rpm_models(3)
for unit in units:
unit.metadata['relativepath'] = 'test-relative-path'
result = associate_already_downloaded_units(models.RPM.TYPE, units, self.conduit)
self.assertEqual(len(list(result)), 3)
示例4: test_rpms_to_download
def test_rpms_to_download(self, mock_package_list_generator, mock_create_downloader):
"""
test with only RPMs specified to download
"""
file_handle = StringIO()
self.metadata_files.get_metadata_file_handle = mock.MagicMock(
spec_set=self.metadata_files.get_metadata_file_handle,
side_effect=[file_handle, None], # None means it will skip DRPMs
)
rpms = model_factory.rpm_models(3)
for rpm in rpms:
rpm.metadata['relativepath'] = self.RELATIVEPATH
mock_package_list_generator.return_value = rpms
self.downloader.download = mock.MagicMock(spec_set=self.downloader.download)
mock_create_downloader.return_value = self.downloader
# call download, passing in only two of the 3 rpms as units we want
report = self.reposync.download(self.metadata_files, set(m.as_named_tuple for m in rpms[:2]), set())
# make sure we skipped DRPMs
self.assertEqual(self.downloader.download.call_count, 1)
self.assertEqual(mock_package_list_generator.call_count, 1)
# verify that the download requests were correct
requests = list(self.downloader.download.call_args[0][0])
self.assertEqual(len(requests), 2)
self.assertEqual(requests[0].url, os.path.join(self.url, self.RELATIVEPATH))
self.assertEqual(requests[0].destination, os.path.join(self.reposync.tmp_dir, self.RELATIVEPATH))
self.assertTrue(requests[0].data is rpms[0])
self.assertEqual(requests[1].url, os.path.join(self.url, self.RELATIVEPATH))
self.assertEqual(requests[1].destination, os.path.join(self.reposync.tmp_dir, self.RELATIVEPATH))
self.assertTrue(requests[1].data is rpms[1])
self.assertTrue(file_handle.closed)
示例5: test_keep_two
def test_keep_two(self):
self.config.override_config[importer_constants.KEY_UNITS_RETAIN_OLD_COUNT] = 1
units = model_factory.rpm_models(3, True)
units.extend(model_factory.rpm_models(2))
for unit in units:
unit.metadata['size'] = 1024
# the generator can yield results out of their original order, which is ok
result = self.reposync._identify_wanted_versions(units)
self.assertFalse(units[0].as_named_tuple in result)
self.assertTrue(units[1].as_named_tuple in result)
self.assertTrue(units[2].as_named_tuple in result)
self.assertTrue(units[3].as_named_tuple in result)
self.assertTrue(units[4].as_named_tuple in result)
for size in result.values():
self.assertEqual(size, 1024)
示例6: test_keep_all
def test_keep_all(self):
self.config.override_config[importer_constants.KEY_UNITS_RETAIN_OLD_COUNT] = None
units = model_factory.rpm_models(3)
for unit in units:
unit.metadata['size'] = 1024
result = sorted(self.reposync._identify_wanted_versions(units).keys())
self.assertEqual([u.as_named_tuple for u in units], result)
示例7: test_with_to_download
def test_with_to_download(self):
units = model_factory.rpm_models(3)
# specify which we want
to_download = set([unit.as_named_tuple for unit in units[:2]])
result = list(self.reposync._filtered_unit_generator(units, to_download))
# make sure we only got the ones we want
self.assertEqual(result, units[:2])
示例8: test_no_epoch
def test_no_epoch(self):
rpm = model_factory.rpm_models(1)[0]
# simulates repos that don't have epochs in their errata
rpm.epoch = None
ret = associate._no_checksum_clean_unit_key(rpm.as_named_tuple)
self.assertTrue(isinstance(ret, dict))
self.assertTrue('epoch' not in ret)
示例9: test_rpm
def test_rpm(self, mock_copyfile):
model = model_factory.rpm_models(1)[0]
unit = Unit(model.TYPE, model.unit_key, model.metadata, '/')
# passing "None" ensures that the importer isn't being called
ret = associate._associate_unit('', None, unit)
self.assertTrue(ret is unit)
self.assertEqual(mock_copyfile.call_count, 0)
示例10: test_all
def test_all(self):
rpm = model_factory.rpm_models(1)[0]
ret = associate._no_checksum_clean_unit_key(rpm.as_named_tuple)
self.assertTrue(isinstance(ret, dict))
self.assertTrue('checksum' not in ret)
self.assertTrue('checksumtype' not in ret)
for key in ['name', 'epoch', 'version', 'release', 'arch']:
self.assertEqual(ret[key], rpm.unit_key[key])
示例11: test_some_existing
def test_some_existing(self):
postfix = model_factory.rpm_models(1)[0]
postfix.name = 'postfix'
vim = model_factory.rpm_models(1)[0]
vim.name = 'vim-common'
existing = [
Unit(postfix.TYPE, postfix.unit_key, postfix.metadata, ''),
Unit(vim.TYPE, vim.unit_key, vim.metadata, ''),
]
conduit = ImportUnitConduit('', '','', '', '', '')
conduit.get_destination_units = mock.MagicMock(spec_set=conduit.get_destination_units,
return_value=existing)
ret = associate.get_rpms_to_copy_by_name(self.RPM_NAMES, conduit)
self.assertEqual(set(ret), set(['python-mock']))
self.assertEqual(conduit.get_destination_units.call_count, 1)
self.assertTrue(isinstance(conduit.get_destination_units.call_args[0][0], UnitAssociationCriteria))
self.assertEqual(conduit.get_destination_units.call_args[0][0].type_ids, [models.RPM.TYPE])
self.assertEqual(conduit.get_destination_units.call_args[0][0].unit_fields, models.RPM.UNIT_KEY_NAMES)
示例12: test_rpms_check_all_and_associate_positive
def test_rpms_check_all_and_associate_positive(self, mock_isfile, mock_save, mock_search_all_units):
units = model_factory.rpm_models(3)
mock_search_all_units.return_value = units
mock_isfile.return_value = True
input_units = set([unit.as_named_tuple for unit in units])
for unit in units:
unit.metadata['filename'] = 'test-filename'
unit.storage_path = "existing_storage_path"
result = check_all_and_associate(input_units, self.conduit)
self.assertEqual(len(list(result)), 0)
# verify we are saving the storage path
for c in mock_save.mock_calls:
(conduit, unit) = c[1]
self.assertEquals(unit.storage_path, "existing_storage_path")
示例13: test_remove_missing_units
def test_remove_missing_units(self, mock_get_existing):
self.conduit.remove_unit = mock.MagicMock(spec_set=self.conduit.remove_unit)
# setup such that only one of the 2 existing units appears to be present
# in the remote repo, thus the other unit should be purged
mock_get_existing.return_value = model_factory.rpm_units(2)
remote_named_tuples = set(model.as_named_tuple for model in model_factory.rpm_models(2))
common_unit = mock_get_existing.return_value[1]
common_named_tuple = models.RPM.NAMEDTUPLE(**common_unit.unit_key)
remote_named_tuples.add(common_named_tuple)
purge.remove_missing_units(self.conduit, models.RPM, remote_named_tuples)
mock_get_existing.assert_called_once_with(models.RPM, self.conduit.get_units)
self.conduit.remove_unit.assert_called_once_with(mock_get_existing.return_value[0])
示例14: test_rpm
def test_rpm(self, mock_open, mock_package_list_generator):
rpms = model_factory.rpm_models(2)
mock_package_list_generator.return_value = rpms
fake_file = StringIO()
mock_open.return_value = fake_file
process_func = lambda x: x
ret = purge.get_remote_units(self.metadata_files, self.FAKE_TYPE, 'bar', process_func)
mock_open.assert_called_once_with('/a/b/c', 'r')
self.assertTrue(fake_file.closed)
mock_package_list_generator.assert_called_once_with(fake_file, 'bar', process_func)
self.assertEqual(len(rpms), len(ret))
for model in rpms:
self.assertTrue(model.as_named_tuple in ret)
示例15: test_with_existing_deps
def test_with_existing_deps(self, mock_find, mock_get_existing):
conduit = mock.MagicMock()
rpms = model_factory.rpm_units(1)
deps = model_factory.rpm_models(2)
dep_units = [Unit(model.TYPE, model.unit_key, model.metadata, '') for model in deps]
mock_find.return_value = [r.as_named_tuple for r in deps]
mock_get_existing.return_value = dep_units
associate.copy_rpms(rpms, conduit, True)
self.assertEqual(conduit.associate_unit.call_count, 1)
self.assertEqual(mock_find.call_count, 1)
self.assertEqual(mock_find.call_args[0][0], set(rpms))
# called once directly, and once from filter_available_rpms
self.assertEqual(mock_get_existing.call_count, 2)