本文整理匯總了Python中iso_distributor.distributor.ISODistributor._publish_isos方法的典型用法代碼示例。如果您正苦於以下問題:Python ISODistributor._publish_isos方法的具體用法?Python ISODistributor._publish_isos怎麽用?Python ISODistributor._publish_isos使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類iso_distributor.distributor.ISODistributor
的用法示例。
在下文中一共展示了ISODistributor._publish_isos方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: TestPublishIsos
# 需要導入模塊: from iso_distributor.distributor import ISODistributor [as 別名]
# 或者: from iso_distributor.distributor.ISODistributor import _publish_isos [as 別名]
class TestPublishIsos(unittest.TestCase):
"""
Tests the _publish_isos method in GroupISODistributor. This method decides what the publishing
directories should be, cleans them up, and hands everything off to the publish_iso method in
export_utils.
"""
def setUp(self):
self.distributor = ISODistributor()
self.repo = Repository('repo_id', working_dir='/working/dir')
self.config = {PUBLISH_HTTP_KEYWORD: True, PUBLISH_HTTPS_KEYWORD: True}
self.publish_iso = export_utils.publish_isos
export_utils.publish_isos = mock.Mock()
def tearDown(self):
export_utils.publish_isos = self.publish_iso
@mock.patch('shutil.rmtree', autospec=True)
def test_publish_isos(self, mock_rmtree):
"""
Test that publish_isos is called with the expected arguments
"""
# Setup
http_publish_dir = os.path.join(EXPORT_HTTP_DIR, self.repo.id)
https_publish_dir = os.path.join(EXPORT_HTTPS_DIR, self.repo.id)
# Test
self.distributor._publish_isos(self.repo, PluginCallConfiguration({}, self.config))
self.assertEqual(2, mock_rmtree.call_count)
self.assertEqual(http_publish_dir, mock_rmtree.call_args_list[0][0][0])
self.assertEqual(https_publish_dir, mock_rmtree.call_args_list[1][0][0])
export_utils.publish_isos.assert_called_once_with(self.repo.working_dir, self.repo.id,
http_publish_dir, https_publish_dir, None,
None)
@mock.patch('shutil.rmtree', autospec=True)
def test_publish_http_https_false(self, mock_rmtree):
"""
Test that when the config has publishing http and https set to false, publish_isos is called
with None for https_dir and http_dir
"""
# Setup
self.config[PUBLISH_HTTPS_KEYWORD] = False
self.config[PUBLISH_HTTP_KEYWORD] = False
self.distributor._publish_isos(self.repo, PluginCallConfiguration({}, self.config))
http_publish_dir = os.path.join(EXPORT_HTTP_DIR, self.repo.id)
https_publish_dir = os.path.join(EXPORT_HTTPS_DIR, self.repo.id)
# Test
self.assertEqual(2, mock_rmtree.call_count)
self.assertEqual(http_publish_dir, mock_rmtree.call_args_list[0][0][0])
self.assertEqual(https_publish_dir, mock_rmtree.call_args_list[1][0][0])
export_utils.publish_isos.assert_called_once_with(self.repo.working_dir, self.repo.id, None,
None, None, None)