Github user mxmrlv commented on a diff in the pull request:

    https://github.com/apache/incubator-ariatosca/pull/12#discussion_r84592475
  
    --- Diff: tests/workflows/api/test_task_graph.py ---
    @@ -0,0 +1,658 @@
    +# Licensed to the Apache Software Foundation (ASF) under one or more
    +# contributor license agreements.  See the NOTICE file distributed with
    +# this work for additional information regarding copyright ownership.
    +# The ASF licenses this file to You under the Apache License, Version 2.0
    +# (the "License"); you may not use this file except in compliance with
    +# the License.  You may obtain a copy of the License at
    +#
    +#     http://www.apache.org/licenses/LICENSE-2.0
    +#
    +# Unless required by applicable law or agreed to in writing, software
    +# distributed under the License is distributed on an "AS IS" BASIS,
    +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +# See the License for the specific language governing permissions and
    +# limitations under the License.
    +
    +from uuid import uuid4
    +
    +import pytest
    +
    +from aria.workflows.api.task_graph import TaskGraph, TaskNotInGraphError
    +
    +
    +class MockTask(object):
    +    def __init__(self):
    +        self.id = str(uuid4())
    +
    +
    +@pytest.fixture
    +def graph():
    +    return TaskGraph(name='mock-graph')
    +
    +
    +class TestTaskGraphTasks(object):
    +
    +    def test_add_task(self, graph):
    +        task = MockTask()
    +        add_result = graph.add_task(task)
    +        assert add_result is True
    +        tasks = [t for t in graph.tasks]
    +        assert len(tasks) == 1
    +        assert tasks[0] == task
    +
    +    def test_add_existing_task(self, graph):
    +        task = MockTask()
    +        graph.add_task(task)
    +        # adding a task already in graph - should have no effect, and 
return False
    +        add_result = graph.add_task(task)
    +        assert add_result is False
    +        tasks = [t for t in graph.tasks]
    +        assert len(tasks) == 1
    +        assert tasks[0] == task
    +
    +    def test_remove_task(self, graph):
    +        task = MockTask()
    +        other_task = MockTask()
    +        graph.add_task(task)
    +        graph.add_task(other_task)
    +        graph.remove_task(other_task)
    +        tasks = [t for t in graph.tasks]
    +        assert len(tasks) == 1
    +        assert tasks[0] == task
    +
    +    def test_remove_task_with_dependency(self, graph):
    +        task = MockTask()
    +        dependent_task = MockTask()
    +        graph.add_task(task)
    +        graph.add_task(dependent_task)
    +        graph.add_dependency(dependent_task, task)
    +        remove_result = graph.remove_task(dependent_task)
    +        assert remove_result is True
    +        tasks = [t for t in graph.tasks]
    +        assert len(tasks) == 1
    +        assert tasks[0] == task
    +        # asserting no dependencies are left for the dependent task
    +        assert len(list(graph.get_task_dependencies(task))) == 0
    +
    +    def test_remove_nonexistent_task(self, graph):
    +        task = MockTask()
    +        task_not_in_graph = MockTask()
    +        graph.add_task(task)
    +        # removing a task not in graph - should have no effect, and return 
False
    +        remove_result = graph.remove_task(task_not_in_graph)
    +        assert remove_result is False
    +        tasks = [t for t in graph.tasks]
    +        assert len(tasks) == 1
    +        assert tasks[0] == task
    +
    +    def test_has_task(self, graph):
    +        task = MockTask()
    +        graph.add_task(task)
    +        assert graph.has_task(task) is True
    +
    +    def test_has_nonexistent_task(self, graph):
    +        task = MockTask()
    +        task_not_in_graph = MockTask()
    +        graph.add_task(task)
    +        assert graph.has_task(task_not_in_graph) is False
    +
    +    def test_get_task(self, graph):
    +        task = MockTask()
    +        graph.add_task(task)
    +        assert graph.get_task(task.id) == task
    +
    +    def test_get_nonexistent_task(self, graph):
    +        task = MockTask()
    +        task_not_in_graph = MockTask()
    +        graph.add_task(task)
    +        with pytest.raises(TaskNotInGraphError):
    +            graph.get_task(task_not_in_graph.id)
    +
    +
    +class TestTaskGraphGraphTraversal(object):
    +
    +    def test_tasks_iteration(self, graph):
    +        task = MockTask()
    +        other_task = MockTask()
    +        graph.add_task(task)
    +        graph.add_task(other_task)
    +        tasks = [t for t in graph.tasks]
    +        assert set(tasks) == {task, other_task}
    --- End diff --
    
    I think that the {x,y} isn't supported in 2.6


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to