當前位置: 首頁>>代碼示例>>Python>>正文


Python ISODistributor.generate_isos方法代碼示例

本文整理匯總了Python中iso_distributor.distributor.ISODistributor.generate_isos方法的典型用法代碼示例。如果您正苦於以下問題:Python ISODistributor.generate_isos方法的具體用法?Python ISODistributor.generate_isos怎麽用?Python ISODistributor.generate_isos使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在iso_distributor.distributor.ISODistributor的用法示例。


在下文中一共展示了ISODistributor.generate_isos方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_generate_isos

# 需要導入模塊: from iso_distributor.distributor import ISODistributor [as 別名]
# 或者: from iso_distributor.distributor.ISODistributor import generate_isos [as 別名]
    def test_generate_isos(self):
        repo = mock.Mock(spec=Repository)
        repo.id = "test_repo_for_export"
        repo.working_dir = self.repo_iso_working_dir
        global progress_status
        progress_status = None

        def set_progress(progress):
            global progress_status
            progress_status = progress

        publish_conduit = distributor_mocks.get_publish_conduit(pkg_dir=self.pkg_dir)
        config = distributor_mocks.get_basic_config(
            https_publish_dir=self.https_publish_dir,
            http_publish_dir=self.http_publish_dir,
            generate_metadata=True,
            http=True,
            https=False,
            prefix="test-isos",
        )
        distributor = ISODistributor()

        def cleanup():
            return

        distributor.cleanup = mock.Mock()
        distributor.cleanup.side_effect = cleanup
        publish_conduit.set_progress = mock.Mock()
        publish_conduit.set_progress.side_effect = set_progress
        progress_status = distributor.init_progress()
        distributor.publish_repo(repo, publish_conduit, config)
        repo.id = "test_mock_iso_prefix"
        distributor.generate_isos(repo.working_dir, "%s/%s" % (self.http_publish_dir, repo.id), prefix="test-isos")

        self.assertTrue("isos" in progress_status)
        self.assertTrue(progress_status["isos"].has_key("state"))
        self.assertEqual(progress_status["isos"]["state"], "FINISHED")
        self.assertEqual(progress_status["isos"]["num_success"], 1)
        self.assertTrue(progress_status["isos"]["size_total"] is not None)
        self.assertEqual(progress_status["isos"]["size_left"], 0)
        self.assertEqual(progress_status["isos"]["items_total"], 1)
        self.assertEqual(progress_status["isos"]["items_left"], 0)

        print progress_status
        self.assertTrue(os.path.exists("%s/%s" % (self.http_publish_dir, repo.id)))
        self.assertEquals(len(os.listdir(self.https_publish_dir)), 0)
        isos_list = os.listdir("%s/%s" % (self.http_publish_dir, repo.id))
        print isos_list
        self.assertEqual(len(isos_list), 1)
        # make sure the iso name defaults to repoid
        self.assertTrue(isos_list[0].startswith("test-isos"))
開發者ID:jlsherrill,項目名稱:pulp,代碼行數:53,代碼來源:test_iso_distributor.py


注:本文中的iso_distributor.distributor.ISODistributor.generate_isos方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。