ariatosca-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mxmrlv <...@git.apache.org>
Subject [GitHub] incubator-ariatosca pull request #12: ARIA-3 Create an API for creating work...
Date Mon, 07 Nov 2016 14:39:14 GMT
Github user mxmrlv commented on a diff in the pull request:

    https://github.com/apache/incubator-ariatosca/pull/12#discussion_r86781784
  
    --- Diff: tests/workflows/api/test_task_graph.py ---
    @@ -298,8 +491,139 @@ def test_remove_dependency_nonexistent_dependency(self, graph):
             with pytest.raises(task_graph.TaskNotInGraphError):
                 graph.remove_dependency(task, task_not_in_graph)
     
    +    def test_remove_dependency_empty_dependent(self, graph):
    +        task = MockTask()
    +        graph.add_tasks(task)
    +        # expecting remove_dependency result to be False - no dependency has been created
    +        assert graph.remove_dependency([], task) is False
    +
    +    def test_remove_dependency_empty_dependency(self, graph):
    +        task = MockTask()
    +        graph.add_tasks(task)
    +        # expecting remove_dependency result to be False - no dependency has been created
    +        assert graph.remove_dependency(task, []) is False
    +
    +    def test_remove_dependency_dependent_group(self, graph):
    +        task = MockTask()
    +        group_tasks = [MockTask() for _ in xrange(3)]
    +        graph.add_tasks(task)
    +        graph.add_tasks(*group_tasks)
    +        graph.add_dependency(group_tasks, task)
    +        remove_result = graph.remove_dependency(group_tasks, task)
    +        assert remove_result is True
    +        assert graph.has_dependency(group_tasks[0], task) is False
    +        assert graph.has_dependency(group_tasks[1], task) is False
    +        assert graph.has_dependency(group_tasks[2], task) is False
    +
    +    def test_remove_dependency_dependency_group(self, graph):
    +        task = MockTask()
    +        group_tasks = [MockTask() for _ in xrange(3)]
    +        graph.add_tasks(task)
    +        graph.add_tasks(*group_tasks)
    +        graph.add_dependency(task, group_tasks)
    +        remove_result = graph.remove_dependency(task, group_tasks)
    +        assert remove_result is True
    +        assert graph.has_dependency(task, group_tasks[0]) is False
    +        assert graph.has_dependency(task, group_tasks[1]) is False
    +        assert graph.has_dependency(task, group_tasks[2]) is False
    +
    +    def test_remove_dependency_between_groups(self, graph):
    +        group_1_tasks = [MockTask() for _ in xrange(3)]
    +        group_2_tasks = [MockTask() for _ in xrange(3)]
    +        graph.add_tasks(*group_1_tasks)
    +        graph.add_tasks(*group_2_tasks)
    +        graph.add_dependency(group_2_tasks, group_1_tasks)
    +        remove_result = graph.remove_dependency(group_2_tasks, group_1_tasks)
    +        assert remove_result is True
    +        for group_2_task in group_2_tasks:
    +            assert graph.has_dependency(group_2_task, group_1_tasks[0]) is False
    +            assert graph.has_dependency(group_2_task, group_1_tasks[1]) is False
    +            assert graph.has_dependency(group_2_task, group_1_tasks[2]) is False
    +
    +    def test_remove_dependency_dependency_group_with_some_existing_dependencies(self,
graph):
    +        task = MockTask()
    +        group_tasks = [MockTask() for _ in xrange(3)]
    +        graph.add_tasks(task)
    +        graph.add_tasks(*group_tasks)
    +        graph.add_dependency(task, group_tasks[1])
    +        remove_result = graph.remove_dependency(task, group_tasks)
    +        # only a partial dependency exists - remove_dependency is expected to return
False
    +        assert remove_result is False
    +        # no dependencies are expected to have changed
    +        assert graph.has_dependency(task, group_tasks[0]) is False
    +        assert graph.has_dependency(task, group_tasks[1]) is True
    +        assert graph.has_dependency(task, group_tasks[2]) is False
    +
    +    def test_remove_nonexistent_dependency_between_groups(self, graph):
    +        group_1_tasks = [MockTask() for _ in xrange(3)]
    +        group_2_tasks = [MockTask() for _ in xrange(3)]
    +        graph.add_tasks(*group_1_tasks)
    +        graph.add_tasks(*group_2_tasks)
    +        # removing a dependency not in graph - should have no effect, and return False
    +        remove_result = graph.remove_dependency(group_2_tasks, group_1_tasks)
    +        assert remove_result is False
    +
    +    # nested tests
    +
    +    def test_group_with_nested_sequence(self, graph):
    +        all_tasks = [MockTask() for _ in xrange(5)]
    +        graph.add_tasks(all_tasks[0],
    +                        graph.sequence(all_tasks[1], all_tasks[2], all_tasks[3]),
    +                        all_tasks[4])
    +        assert set(graph.tasks) == set(all_tasks)
    +
    +        # tasks[2] and tasks[3] should each have a single dependency; the rest should
have none
    +        assert len(list(graph.get_dependencies(all_tasks[0]))) == 0
    +        assert len(list(graph.get_dependencies(all_tasks[1]))) == 0
    +        assert set(graph.get_dependencies(all_tasks[2])) == set([all_tasks[1]])
    +        assert set(graph.get_dependencies(all_tasks[3])) == set([all_tasks[2]])
    +        assert len(list(graph.get_dependencies(all_tasks[4]))) == 0
    +
    +    def test_group_with_nested_group(self, graph):
    +        tasks = [MockTask() for _ in xrange(5)]
    +        graph.add_tasks(tasks[0], (tasks[1], tasks[2], tasks[3]), tasks[4])
    +        graph_tasks = [t for t in graph.tasks]
    +        assert set(graph_tasks) == set(tasks)
    +        # none of the tasks should have any dependencies
    +        for i in xrange(len(tasks)):
    +            assert len(list(graph.get_dependencies(tasks[i]))) == 0
    +
    +    def test_group_with_recursively_nested_group(self, graph):
    --- End diff --
    
    delete


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message