本文整理匯總了Python中pulp_rpm.plugins.distributors.export_distributor.distributor.ISODistributor.publish_repo方法的典型用法代碼示例。如果您正苦於以下問題:Python ISODistributor.publish_repo方法的具體用法?Python ISODistributor.publish_repo怎麽用?Python ISODistributor.publish_repo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pulp_rpm.plugins.distributors.export_distributor.distributor.ISODistributor
的用法示例。
在下文中一共展示了ISODistributor.publish_repo方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_publish_repo
# 需要導入模塊: from pulp_rpm.plugins.distributors.export_distributor.distributor import ISODistributor [as 別名]
# 或者: from pulp_rpm.plugins.distributors.export_distributor.distributor.ISODistributor import publish_repo [as 別名]
def test_publish_repo(self, mock_validate, export_publisher, mock_ensure_downloaded):
mock_validate.return_value = (True, None)
distributor = ISODistributor()
export_publisher.return_value = mock.Mock()
export_publisher.return_value.process_lifecycle.return_value = 'foo'
self.assertEquals('foo', distributor.publish_repo(self.repo, self.conduit, self.config))
示例2: test_publish_repo
# 需要導入模塊: from pulp_rpm.plugins.distributors.export_distributor.distributor import ISODistributor [as 別名]
# 或者: from pulp_rpm.plugins.distributors.export_distributor.distributor.ISODistributor import publish_repo [as 別名]
def test_publish_repo(self, mock_validate, export_publisher):
mock_validate.return_value = (True, None)
distributor = ISODistributor()
export_publisher.return_value = mock.Mock()
export_publisher.return_value.publish.return_value = 'foo'
self.assertEquals('foo', distributor.publish_repo(self.repo, self.conduit, self.config))
示例3: TestPublishRepo
# 需要導入模塊: from pulp_rpm.plugins.distributors.export_distributor.distributor import ISODistributor [as 別名]
# 或者: from pulp_rpm.plugins.distributors.export_distributor.distributor.ISODistributor import publish_repo [as 別名]
class TestPublishRepo(unittest.TestCase):
"""
Tests publish_repo in ISODistributor
"""
def setUp(self):
self.config_dict = {
PUBLISH_HTTP_KEYWORD: False,
PUBLISH_HTTPS_KEYWORD: True
}
# Set up the distributor
self.distributor = ISODistributor()
self.distributor._publish_isos = mock.Mock(spec=ISODistributor._publish_isos)
# Arguments for the distributor
self.repo = Repository(id='repo-id', working_dir='/working/dir')
self.mock_conduit = mock.Mock(spec=RepoPublishConduit)
self.config = PluginCallConfiguration({}, self.config_dict)
# It's difficult to mock patch the export_utils, so do it here.
self.cleanup_working_dir = export_utils.cleanup_working_dir
self.validate_export_config = export_utils.validate_export_config
self.export_complete_repo = export_utils.export_complete_repo
self.export_incremental = export_utils.export_incremental_content
self.retrieve_repo_config = export_utils.retrieve_repo_config
self.generate_listing_files = util.generate_listing_files
self.rmtree = shutil.rmtree
self.makdirs = os.makedirs
export_utils.cleanup_working_dir = mock.Mock(spec=export_utils.cleanup_working_dir)
export_utils.validate_export_config = mock.Mock(return_value=(True, None))
export_utils.export_complete_repo = mock.Mock(return_value=({}, {'errors': []}))
export_utils.export_incremental_content = mock.Mock(return_value=({}, {'errors': ()}))
export_utils.retrieve_repo_config = mock.Mock(return_value=('/working/dir/repo', None))
util.generate_listing_files = mock.Mock()
shutil.rmtree = mock.Mock(spec=shutil.rmtree)
os.makedirs = mock.Mock(spec=os.makedirs)
def tearDown(self):
export_utils.cleanup_working_dir = self.cleanup_working_dir
export_utils.validate_export_config = self.validate_export_config
export_utils.export_complete_repo = self.export_complete_repo
export_utils.export_incremental_content = self.export_incremental
export_utils.retrieve_repo_config = self.retrieve_repo_config
util.generate_listing_files = self.generate_listing_files
shutil.rmtree = self.rmtree
os.makedirs = self.makdirs
def test_failed_override_config(self):
"""
Tests that when invalid override configuration is given, an exception is raised.
"""
# Setup
export_utils.validate_export_config.return_value = (False, 'failed validation')
# Test
self.assertRaises(PulpDataException, self.distributor.publish_repo, self.repo,
self.mock_conduit, self.config)
def test_working_dir_cleanup(self):
"""
Check that the working directory is cleaned before use. This is done because the ISOs are
currently stored there
"""
self.distributor.publish_repo(self.repo, self.mock_conduit, self.config)
shutil.rmtree.assert_called_once_with(self.repo.working_dir, ignore_errors=True)
os.makedirs.assert_called_once_with(self.repo.working_dir)
def test_export_with_export_dir(self):
"""
Test that _publish_isos isn't called when there is an export directory in the config, and that
the correct working directory is used.
"""
# Set the config to have an export directory
self.config_dict[EXPORT_DIRECTORY_KEYWORD] = '/my/export/dir'
config = PluginCallConfiguration({}, self.config_dict)
# Test
self.distributor.publish_repo(self.repo, self.mock_conduit, config)
self.assertEqual(0, self.distributor._publish_isos.call_count)
self.assertEqual(1, self.mock_conduit.build_success_report.call_count)
def test_export_iso_publish(self):
"""
Test that _publish_iso gets called when an export dir isn't in the config
"""
self.distributor.publish_repo(self.repo, self.mock_conduit, self.config)
self.assertEqual(1, self.distributor._publish_isos.call_count)
self.assertEqual(self.repo, self.distributor._publish_isos.call_args[0][0])
self.assertEqual(self.config, self.distributor._publish_isos.call_args[0][1])
self.assertEqual(1, self.mock_conduit.build_success_report.call_count)
def test_export_complete_repo(self):
"""
Test that when a date filter doesn't exist, export_complete_repo is called
"""
self.distributor.publish_repo(self.repo, self.mock_conduit, self.config)
self.assertEqual(1, export_utils.export_complete_repo.call_count)
self.assertEqual('repo-id', export_utils.export_complete_repo.call_args[0][0])
self.assertEqual('/working/dir/repo', export_utils.export_complete_repo.call_args[0][1])
#.........這裏部分代碼省略.........