def test_should_find_long_nontrivial_cycle_in_graph_when_there_are_two(
         self):
     graph_with_long_cycle = Graph({
         "a": "b",
         "b": "c",
         "c": "a",
         "d": "e",
         "e": "f",
         "f": "d"
     })
     self.assertIsNotNone(graph_with_long_cycle.assert_no_cycles_present())
示例#2
0
    def build_execution_plan(self, task_names):
        self.assert_dependencies_resolved()

        execution_plan = []

        dependency_edges = {}
        for task in self.collect_all_transitive_tasks(as_list(task_names)):
            dependency_edges[task.name] = task.dependencies
        try:
            Graph(dependency_edges).assert_no_cycles_present()
        except GraphHasCycles as cycles:
            raise CircularTaskDependencyException(str(cycles))

        for task_name in as_list(task_names):
            self.enqueue_task(execution_plan, task_name)
        return execution_plan
 def test_should_not_find_cycles_in_graph_when_there_are_none(self):
     graph_without_cycle = Graph({"a": "b", "b": "c", "d": "e"})
     graph_without_cycle.assert_no_cycles_present()
 def test_should_find_simple_nontrivial_cycle_in_graph_when_there_is_one(
         self):
     graph_with_simple_cycle = Graph({"a": "b", "b": "a"})
     self.assertIsNotNone(
         graph_with_simple_cycle.assert_no_cycles_present())
 def test_should_find_trivial_cycle_in_graph_when_there_are_two(self):
     graph_with_trivial_cycles = Graph({"a": "a", "b": "b"})
     self.assertIsNotNone(
         graph_with_trivial_cycles.assert_no_trivial_cycles_present())
 def test_should_find_trivial_cycle_in_graph_when_searching_for_cycles(
         self):
     graph_with_trivial_cycle = Graph({"a": "a"})
     self.assertIsNotNone(
         graph_with_trivial_cycle.assert_no_cycles_present())
示例#7
0
 def test_should_not_find_cycles_in_graph_when_there_are_none(self):
     graph_without_cycle = Graph({"a": "b", "b": "c", "d": "e"})
     graph_without_cycle.assert_no_cycles_present()
示例#8
0
 def test_should_find_long_nontrivial_cycle_in_graph_when_there_is_one(
         self):
     graph_with_long_cycle = Graph({"a": "b", "b": "c", "c": "d", "d": "b"})
     self.assertRaises(GraphHasCycles,
                       graph_with_long_cycle.assert_no_cycles_present)
示例#9
0
 def test_should_find_trivial_cycle_in_graph_when_searching_for_cycles(
         self):
     graph_with_trivial_cycle = Graph({"a": "a"})
     self.assertRaises(GraphHasCycles,
                       graph_with_trivial_cycle.assert_no_cycles_present)
示例#10
0
 def test_should_find_trivial_cycle_in_graph_when_there_are_two(self):
     graph_with_trivial_cycles = Graph({"a": "a", "b": "b"})
     self.assertRaises(
         GraphHasCycles,
         graph_with_trivial_cycles.assert_no_trivial_cycles_present)
示例#11
0
 def test_should_find_trivial_cycle_in_graph_when_there_is_one(self):
     graph_with_trivial_cycle = Graph({"a": "a"})
     self.assertRaises(
         GraphHasCycles,
         graph_with_trivial_cycle.assert_no_trivial_cycles_present)