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


Python YumDistributor.form_rel_url_lookup_table方法代碼示例

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


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

示例1: test_form_rel_url_lookup_table

# 需要導入模塊: from yum_distributor.distributor import YumDistributor [as 別名]
# 或者: from yum_distributor.distributor.YumDistributor import form_rel_url_lookup_table [as 別名]
    def test_form_rel_url_lookup_table(self):
        distributor = YumDistributor()
        existing_urls = distributor.form_rel_url_lookup_table(None)
        self.assertEqual(existing_urls, {})

        url_a = "/abc/de/fg/"
        config_a = PluginCallConfiguration({"relative_url":url_a}, {})
        repo_a = RelatedRepository("repo_a_id", [config_a])

        conflict_url_a = "/abc/de/"
        conflict_config_a = PluginCallConfiguration({"relative_url":conflict_url_a}, {})
        conflict_repo_a = RelatedRepository("conflict_repo_id_a", [conflict_config_a])

        url_b = "/abc/de/kj/"
        config_b = PluginCallConfiguration({"relative_url":url_b}, {})
        repo_b = RelatedRepository("repo_b_id", [config_b])
        repo_b_dup = RelatedRepository("repo_b_dup_id", [config_b])

        url_c = "/abc/jk/fg/gfgf/gfgf/gfre/"
        config_c = PluginCallConfiguration({"relative_url":url_c}, {})
        repo_c = RelatedRepository("repo_c_id", [config_c])

        url_d = "simple"
        config_d = PluginCallConfiguration({"relative_url":url_d}, {})
        repo_d = RelatedRepository("repo_d_id", [config_d])

        url_e = ""
        config_e = PluginCallConfiguration({"relative_url":url_e}, {})
        repo_e = RelatedRepository("repo_e_id", [config_e])

        url_f = "/foo"
        config_f = PluginCallConfiguration({"relative_url":url_f}, {})
        repo_f = RelatedRepository("repo_f_id", [config_f])

        conflict_url_f = "foo/"
        conflict_config_f = PluginCallConfiguration({"relative_url":conflict_url_f}, {})
        conflict_repo_f = RelatedRepository("conflict_repo_f_id", [conflict_config_f])

        url_g = "bar/"
        config_g = PluginCallConfiguration({"relative_url":url_g}, {})
        repo_g = RelatedRepository("repo_g_id", [config_g])

        # Try with url set to None
        url_h = None
        config_h = PluginCallConfiguration({"relative_url":url_h}, {})
        repo_h = RelatedRepository("repo_h_id", [config_h])

        # Try with relative_url not existing
        config_i = PluginCallConfiguration({}, {})
        repo_i = RelatedRepository("repo_i_id", [config_i])

        existing_urls = distributor.form_rel_url_lookup_table([repo_a, repo_d, repo_e, repo_f, repo_g, repo_h])
        self.assertEqual(existing_urls, {'simple': {'repo_id': repo_d.id, 'url': url_d},
            'abc': {'de': {'fg': {'repo_id': repo_a.id, 'url': url_a}}},
            repo_e.id : {'repo_id': repo_e.id, 'url': repo_e.id}, # url_e is empty so we default to use repo id
            repo_h.id : {'repo_id': repo_h.id, 'url': repo_h.id}, # urk_h is None so we default to use repo id
            'bar': {'repo_id': repo_g.id, 'url':url_g}, 'foo': {'repo_id': repo_f.id, 'url': url_f}})

        existing_urls = distributor.form_rel_url_lookup_table([repo_a])
        self.assertEqual(existing_urls, {'abc': {'de': {'fg': {'repo_id': repo_a.id, 'url': url_a}}}})

        existing_urls = distributor.form_rel_url_lookup_table([repo_a, repo_b])
        self.assertEqual(existing_urls, {'abc': {'de': {'kj': {'repo_id': repo_b.id, 'url': url_b}, 'fg': {'repo_id': repo_a.id, 'url': url_a}}}})

        existing_urls = distributor.form_rel_url_lookup_table([repo_a, repo_b, repo_c])
        self.assertEqual(existing_urls, {'abc': {'de': {'kj': {'repo_id': repo_b.id, 'url':url_b},
            'fg': {'repo_id': repo_a.id, 'url':url_a}}, 'jk': {'fg': {'gfgf': {'gfgf': {'gfre': {'repo_id': repo_c.id, 'url':url_c}}}}}}})

        # Add test for exception on duplicate with repos passed in
        caught = False
        try:
            existing_urls = distributor.form_rel_url_lookup_table([repo_a, repo_b, repo_b_dup, repo_c])
        except Exception, e:
            caught = True
開發者ID:ehelms,項目名稱:pulp,代碼行數:76,代碼來源:test_distributor.py


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