当前位置: 首页>>代码示例>>Python>>正文


Python tools.create_rule函数代码示例

本文整理汇总了Python中tests.dgm.tools.create_rule函数的典型用法代码示例。如果您正苦于以下问题:Python create_rule函数的具体用法?Python create_rule怎么用?Python create_rule使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了create_rule函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_filtered_none_components_deps

 def test_filtered_none_components_deps(self):
     """
     Check that dependencies are not in the graph when they are filtered out.
     RuleSet: #root -> #deps (filter = NONE)
     Components: a#root
     Component a provides a depfinder that returns b#deps
     Expecting: a#root, b#deps (b#deps has no action, it has been filtered out)
     """
     rules = set()
     rules.add(tools.create_rule(ruleset=self.__class__.__name__,
                                 name="R-root",
                                 action="Root Action",
                                 types=["[email protected]"],
                                 depsfinder=tools.getMockDepsFinderCmd(["b#[email protected]"]),
                                 dependson=["R-Deps"]))
     rules.add(tools.create_rule(ruleset=self.__class__.__name__,
                                 name="R-Deps",
                                 action="Deps Action",
                                 types=["[email protected]"],
                                 filter=NONE))
     ruleset = RuleSet(rules)
     depgraph = ruleset.get_depgraph([Component("a#[email protected]")])
     components = depgraph.components_map
     self.assertTrue(components is not None)
     self.assertEquals(len(components), 2)
     self.assertTrue(depgraph.dag is not None)
     self.assertTrue("a#[email protected]" in components)
     self.assertTrue("R-root" in components["a#[email protected]"].actions)
     self.assertEquals("Root Action", components["a#[email protected]"].actions["R-root"])
     self.assertTrue("b#[email protected]" in components)
     self.assertTrue(depgraph.dag.has_node("a#[email protected]"))
     self.assertTrue(depgraph.dag.has_node("b#[email protected]"))
     self.assertTrue("Deps Action" not in components["b#[email protected]"].actions)
开发者ID:af-bull,项目名称:sequencer,代码行数:33,代码来源:testmodel_depgraph_basic.py

示例2: test_a_nop_b

 def test_a_nop_b(self):
     """
     Check that action NONE are understood correctly.
     RuleSet: #root, #dep (filter = ALL),
     a#root -> b#dep (a.action=NONE)
     Expecting: a#root -> b#dep
     But a#root has no attribute in the xml graph.
     """
     rules = set()
     rules.add(tools.create_rule(ruleset=self.__class__.__name__,
                                 name="Root",
                                 types=["[email protected]"],
                                 action=NONE,
                                 depsfinder=tools.getMockDepsFinderCmd(["b#[email protected]"]),
                                 dependson=['Dep']))
     rules.add(tools.create_rule(ruleset=self.__class__.__name__,
                                 name="Dep",
                                 types=["[email protected]"],
                                 action="Dep Action"))
     ruleset = RuleSet(rules)
     depgraph = ruleset.get_depgraph([Component("a#[email protected]")])
     components = depgraph.components_map
     self.assertTrue(components is not None)
     self.assertEquals(len(components), 2)
     self.assertTrue("a#[email protected]" in components)
     self.assertTrue("b#[email protected]" in components)
     self.assertTrue(depgraph.dag is not None)
     self.assertTrue(depgraph.dag.has_node("a#[email protected]"))
     self.assertTrue(depgraph.dag.has_node("b#[email protected]"))
     self.assertFalse("Root" in components["a#[email protected]"].actions, components)
     self.assertTrue("Dep" in components["b#[email protected]"].actions)
     attributes = depgraph.dag.node_attributes("a#[email protected]")
     self.assertEquals(len(attributes), 0)
     attributes = depgraph.dag.node_attributes("b#[email protected]")
     self.assertEquals(len(attributes), 1)
开发者ID:af-bull,项目名称:sequencer,代码行数:35,代码来源:testmodel_depgraph_basic.py

示例3: test_checksum_different_types

    def test_checksum_different_types(self):
        rule1 = tools.create_rule(self.__class__.__name__, "R1")
        rule2 = tools.create_rule(self.__class__.__name__, "R2")
        self.db.add_rule(rule1)
        self.db.add_rule(rule2)
        (orig_ruleset_h, orig_h_for) = self.db.checksum(rule1.ruleset)

        self.db.remove_rules(rule1.ruleset)
        rule2 = tools.create_rule(self.__class__.__name__, "R2", types=["[email protected]"])
        self.db.add_rule(rule1)
        self.db.add_rule(rule2)
        (other_ruleset_h, other_h_for) = self.db.checksum(rule1.ruleset)
        self.assertNotEquals(orig_ruleset_h.hexdigest(),
                             other_ruleset_h.hexdigest())
        self.assertNotEquals(orig_h_for["R2"].hexdigest(),
                             other_h_for["R2"].hexdigest())

        self.db.remove_rules(rule1.ruleset)
        rule1 = tools.create_rule(self.__class__.__name__, "R1", types=["[email protected]", "ALL"])
        self.db.add_rule(rule1)
        self.db.add_rule(rule2)
        (other_ruleset_h, other_h_for) = self.db.checksum(rule1.ruleset)
        self.assertNotEquals(orig_ruleset_h.hexdigest(),
                             other_ruleset_h.hexdigest())
        self.assertNotEquals(orig_h_for["R1"].hexdigest(),
                             other_h_for["R1"].hexdigest())
开发者ID:cloax,项目名称:sequencer,代码行数:26,代码来源:abstracttestdb.py

示例4: test_none_rulename_forbidden

 def test_none_rulename_forbidden(self):
     try:
         tools.create_rule(self.__class__.__name__,
                           None)
         self.fail("Setting rule name to None should raise an exception!")
     except ValueError:
         pass
开发者ID:AdrienDebrie,项目名称:sequencer,代码行数:7,代码来源:testmodel_basic.py

示例5: test_multiple_actions_cycle

    def test_multiple_actions_cycle(self):
        """
        Check that a given component can contain multiple actions.
        RuleSet: R1:#ta, R2:#ta->R1
        Components: a#ta (R1 depsfinder returns itself: a#ta)
        Expecting: a#ta with 2 actions and a cycle.
        """
        rules = set()
        rules.add(tools.create_rule(ruleset=self.__class__.__name__,
                                    name="R1",
                                    action="Action for a",
                                    types=["ta[email protected]"]))
        rules.add(tools.create_rule(ruleset=self.__class__.__name__,
                                    name="R2",
                                    action="Action for a",
                                    types=["[email protected]"],
                                    depsfinder=tools.getMockDepsFinderCmd(["a#[email protected]"]),
                                    dependson=["R1"]))
        ruleset = RuleSet(rules)
        depgraph = ruleset.get_depgraph([Component("a#[email protected]")])
        components = depgraph.components_map

        self.assertTrue(components is not None)
        self.assertEquals(len(components), 1, "Map: %s" % components)
        self.assertTrue("a#[email protected]" in components)
        self.assertTrue("R1" in components["a#[email protected]"].actions)
        self.assertTrue("R2" in components["a#[email protected]"].actions)
        self.assertEquals(len(components["a#[email protected]"].actions), 2)
        self.assertEquals(len(depgraph.dag.node_attributes("a#[email protected]")), 2)
        self.assertTrue(depgraph.dag.has_edge(("a#[email protected]", "a#[email protected]")))
开发者ID:AdrienDebrie,项目名称:sequencer,代码行数:30,代码来源:testmodel_depgraph.py

示例6: test_simple_deps_ta_tb_b_a_nodepsfinder

 def test_simple_deps_ta_tb_b_a_nodepsfinder(self):
     """
     RuleSet: #ta->#tb,
     Components: b#tb, a#ta (reverse than test_simple_deps_ta_tb_a_b_nodepsfinder)
     Expecting: a#ta, b#tb (order does not count)
     """
     rules = set()
     rules.add(tools.create_rule(ruleset=self.__class__.__name__,
                                 name="Ra",
                                 action="Action for a",
                                 types=["[email protected]"],
                                 dependson=["Rb"]))
     rules.add(tools.create_rule(ruleset=self.__class__.__name__,
                                 name="Rb",
                                 action="Action for b",
                                 types=["[email protected]"]))
     ruleset = RuleSet(rules)
     depgraph = ruleset.get_depgraph([Component("b#[email protected]"),
                                      Component("a#[email protected]")])
     components = depgraph.components_map
     self.assertTrue(components is not None)
     self.assertEquals(len(components), 2)
     self.assertTrue("a#[email protected]" in components)
     self.assertTrue("b#[email protected]" in components)
     self.assertTrue(depgraph.dag is not None)
     self.assertTrue(depgraph.dag.has_node("a#[email protected]"))
     self.assertTrue(depgraph.dag.has_node("b#[email protected]"))
     self.assertNoEdgeBetween(depgraph.dag, "a#[email protected]", "b#[email protected]")
开发者ID:AdrienDebrie,项目名称:sequencer,代码行数:28,代码来源:testmodel_depgraph.py

示例7: test_simple_nodeps_ta_tb_a_b

 def test_simple_nodeps_ta_tb_a_b(self):
     """
     RuleSet: #ta, #tb,
     Components: a#ta, b#tb
     Expecting: a#ta, b#tb
     """
     rules = set()
     rules.add(tools.create_rule(ruleset=self.__class__.__name__,
                                 name="Ra",
                                 action="Action for a",
                                 types=["[email protected]"]))
     rules.add(tools.create_rule(ruleset=self.__class__.__name__,
                                 name="Rb",
                                 action="Action for b",
                                 types=["[email protected]"]))
     ruleset = RuleSet(rules)
     depgraph = ruleset.get_depgraph([Component("a#[email protected]"),
                                      Component("b#[email protected]")])
     components = depgraph.components_map
     self.assertTrue(components is not None)
     self.assertEquals(len(components), 2)
     self.assertTrue("a#[email protected]" in components)
     self.assertTrue("b#[email protected]" in components)
     self.assertTrue(depgraph.dag is not None)
     self.assertTrue(depgraph.dag.has_node("a#[email protected]"))
     self.assertTrue(depgraph.dag.has_node("b#[email protected]"))
     self.assertTrue("Ra" in components["a#[email protected]"].actions)
     self.assertEquals("Action for a", components["a#[email protected]"].actions["Ra"])
     self.assertTrue("Rb" in components["b#[email protected]"].actions)
     self.assertEquals("Action for b", components["b#[email protected]"].actions["Rb"])
     self.assertNoEdgeBetween(depgraph.dag, "a#[email protected]", "b#[email protected]")
开发者ID:AdrienDebrie,项目名称:sequencer,代码行数:31,代码来源:testmodel_depgraph.py

示例8: test_multiple_actions_nodeps

    def test_multiple_actions_nodeps(self):
        """
        Check that a given component can contain multiple actions.
        RuleSet: #ta, #ta
        Components: a#ta
        Expecting: a#ta with 2 actions.
        """
        rules = set()
        rules.add(tools.create_rule(ruleset=self.__class__.__name__,
                                    name="R1",
                                    action="Action for a",
                                    types=["[email protected]"]))
        rules.add(tools.create_rule(ruleset=self.__class__.__name__,
                                    name="R2",
                                    action="Action for a",
                                    types=["[email protected]"]))
        ruleset = RuleSet(rules)
        depgraph = ruleset.get_depgraph([Component("a#[email protected]")])
        components = depgraph.components_map

        self.assertTrue(components is not None)
        self.assertEquals(len(components), 1, "Map: %s" % components)
        self.assertTrue("a#[email protected]" in components)
        self.assertTrue("R1" in components["a#[email protected]"].actions)
        self.assertTrue("R2" in components["a#[email protected]"].actions)
        self.assertEquals(len(components["a#[email protected]"].actions), 2)
        self.assertEquals(len(depgraph.dag.node_attributes("a#[email protected]")), 2)
开发者ID:AdrienDebrie,项目名称:sequencer,代码行数:27,代码来源:testmodel_depgraph.py

示例9: test_root_in_simple_cycle

    def test_root_in_simple_cycle(self):
        """
        The root is in a simple cycle.
        RuleSet: #ta->#tb, #tb->#tc, #tc->#ta (triangle)
        Components: b#tb
        Expecting: b#tb
        """
        rules = set()
        rules.add(tools.create_rule(ruleset=self.__class__.__name__,
                                    name="Ra",
                                    action="Action for a",
                                    types=["[email protected]"],
                                    dependson=["Rb"]))
        rules.add(tools.create_rule(ruleset=self.__class__.__name__,
                                    name="Rb",
                                    action="Action for b",
                                    types=["[email protected]"],
                                    dependson=["Rc"]))
        rules.add(tools.create_rule(ruleset=self.__class__.__name__,
                                    name="Rc",
                                    action="Action for c",
                                    dependson=["Ra"],
                                    types=["[email protected]"]))
        ruleset = RuleSet(rules)
        depgraph = ruleset.get_depgraph([Component("b#[email protected]")])
        components = depgraph.components_map

        self.assertTrue(components is not None)
        self.assertEquals(len(components), 1, "Map: %s" % components)
        self.assertTrue("b#[email protected]" in components)
        self.assertTrue(depgraph.dag is not None)
        self.assertTrue(depgraph.dag.has_node("b#[email protected]"))
开发者ID:AdrienDebrie,项目名称:sequencer,代码行数:32,代码来源:testmodel_depgraph.py

示例10: test_no_root_with_cycle_in_graph_rules

    def test_no_root_with_cycle_in_graph_rules(self):
        """
        There are no match in the given component list.
        RuleSet: #ta->#tb->#ta
        Components: c#tc
        Expecting: c#tc.
        """
        rules = set()
        rules.add(tools.create_rule(ruleset=self.__class__.__name__,
                                    name="Ra",
                                    action="Action for a",
                                    types=["[email protected]"],
                                    depsfinder=tools.getMockDepsFinderCmd(["foo#[email protected]"]),
                                    dependson=["Rb"]))
        rules.add(tools.create_rule(ruleset=self.__class__.__name__,
                                    name="Rb",
                                    action="Action for b",
                                    types=["[email protected]"],
                                    depsfinder=tools.getMockDepsFinderCmd(["foo#[email protected]"]),
                                    dependson=["Ra"]))

        ruleset = RuleSet(rules)
        depgraph = ruleset.get_depgraph([Component("c#[email protected]")])
        components = depgraph.components_map

        self.assertTrue(components is not None)
        self.assertEquals(len(components), 1, "Map: %s" % components)
        self.assertTrue("c#[email protected]" in components)
        self.assertTrue(depgraph.dag is not None)
        self.assertEquals(len(depgraph.dag.nodes()), 1)
        self.assertTrue(depgraph.dag.has_node("c#[email protected]"))
开发者ID:AdrienDebrie,项目名称:sequencer,代码行数:31,代码来源:testmodel_depgraph.py

示例11: test_simple_deps_ta_tb_b_a_withdepsfinder

    def test_simple_deps_ta_tb_b_a_withdepsfinder(self):
        """
        RuleSet: #ta->#tb,
        Components: b#tb, a#ta (reverse)
        Component a does provide a depfinder that returns b#tb
        Expecting: a#ta -> b#tb
        """
        rules = set()
        rules.add(tools.create_rule(ruleset=self.__class__.__name__,
                                    name="Ra",
                                    action="Action for a",
                                    types=["[email protected]"],
                                    depsfinder=tools.getMockDepsFinderCmd(["b#[email protected]"]),
                                    dependson=["Rb"]))
        rules.add(tools.create_rule(ruleset=self.__class__.__name__,
                                    name="Rb",
                                    action="Action for b",
                                    types=["[email protected]"]))
        ruleset = RuleSet(rules)
        depgraph = ruleset.get_depgraph([Component("b#[email protected]"),
                                         Component("a#[email protected]")])
        components = depgraph.components_map

        self.assertTrue(components is not None)
        self.assertEquals(len(components), 2, "Map: %s" % components)
        self.assertTrue("a#[email protected]" in components)
        self.assertTrue("b#[email protected]" in components)
        self.assertTrue(depgraph.dag is not None)
        self.assertTrue(depgraph.dag.has_node("a#[email protected]"))
        self.assertTrue(depgraph.dag.has_node("b#[email protected]"))
        self.assertTrue(depgraph.dag.has_edge(("a#[email protected]", "b#[email protected]")))
开发者ID:AdrienDebrie,项目名称:sequencer,代码行数:31,代码来源:testmodel_depgraph.py

示例12: test_empty_depsfinder_forbidden

 def test_empty_depsfinder_forbidden(self):
     try:
         tools.create_rule(self.__class__.__name__,
                           "EmptyDepsFinderForbidden",
                           depsfinder="")
         self.fail("Setting an empty depsfinder should raise an exception!")
     except ValueError:
         pass
开发者ID:AdrienDebrie,项目名称:sequencer,代码行数:8,代码来源:testmodel_basic.py

示例13: test_rule_pass_filter_re_category

    def test_rule_pass_filter_re_category(self):
        rule = tools.create_rule("RS", "RN", filter="%category =~ cat")
        self.assertTrue(rule.pass_filter(Component("foo#[email protected]")))
        self.assertFalse(rule.pass_filter(Component("bar#[email protected]")))

        rule = tools.create_rule("RS", "RN", filter="%category !~ cat")
        self.assertFalse(rule.pass_filter(Component("foo#[email protected]")))
        self.assertTrue(rule.pass_filter(Component("bar#[email protected]")))
开发者ID:AdrienDebrie,项目名称:sequencer,代码行数:8,代码来源:testmodel_basic.py

示例14: test_rule_pass_filter_re_type

    def test_rule_pass_filter_re_type(self):
        rule = tools.create_rule("RS", "RN", filter="%type =~ bar")
        self.assertTrue(rule.pass_filter(Component("foo#[email protected]")))
        self.assertFalse(rule.pass_filter(Component("bar#[email protected]")))

        rule = tools.create_rule("RS", "RN", filter="%type !~ bar")
        self.assertFalse(rule.pass_filter(Component("foo#[email protected]")))
        self.assertTrue(rule.pass_filter(Component("bar#[email protected]")))
开发者ID:AdrienDebrie,项目名称:sequencer,代码行数:8,代码来源:testmodel_basic.py

示例15: test_empty_types_forbidden

 def test_empty_types_forbidden(self):
     try:
         tools.create_rule(self.__class__.__name__,
                           "EmptyTypesForbidden",
                           types=set())
         self.fail("Setting an empty set should raise an exception!")
     except ValueError:
         pass
开发者ID:AdrienDebrie,项目名称:sequencer,代码行数:8,代码来源:testmodel_basic.py


注:本文中的tests.dgm.tools.create_rule函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。