Beispiel #1
0
    def test_adding_commands(self):
        t = Task("task 0")
        t.commands([CmdGetProject().resolve(), CmdGetProject().resolve()])

        obj = t.to_map()
        assert 2 == len(obj["commands"])
        assert "git.get_project" == obj["commands"][0]["command"]
Beispiel #2
0
    def test_function_with_vars(self):
        t = Task("task 0")
        t.function_with_vars("fn 0", {"x": "y"})

        obj = t.to_map()
        assert "fn 0" == obj["commands"][0]["func"]
        assert "y" == obj["commands"][0]["vars"]["x"]
Beispiel #3
0
    def test_adding_requires(self):
        t = Task("task 0")
        t.requires(TaskDependency("dep 0")).requires(
            TaskDependency("dep 1")).requires(TaskDependency("dep 2"))

        obj = t.to_map()
        assert 3 == len(obj["requires"])
        assert "dep 1" == obj["requires"][1]["name"]
Beispiel #4
0
    def test_adding_dependencies(self):
        t = Task("task 0")
        t.dependency(TaskDependency("dep 0")).dependency(
            TaskDependency("dep 1")).dependency(TaskDependency("dep 2"))

        obj = t.to_map()
        assert 3 == len(obj["depends_on"])
        assert "dep 1" == obj["depends_on"][1]["name"]
Beispiel #5
0
    def test_functions(self):
        t = Task("task 0")
        t.function("fn 0")
        t.functions(["fn 1", "fn 2"])

        obj = t.to_map()
        assert 3 == len(obj["commands"])
        assert "fn 0" == obj["commands"][0]["func"]
        assert "fn 1" == obj["commands"][1]["func"]
        assert "fn 2" == obj["commands"][2]["func"]
Beispiel #6
0
    def test_task_with_flat_values(self):
        t = Task("task 0")
        t.priority(42)

        obj = t.to_map()
        assert "task 0" == t.get_name()
        assert "task 0" == obj["name"]
        assert 42 == obj["priority"]
Beispiel #7
0
    def test_invalid_function_with_vars(self):
        t = Task("task 0")

        with pytest.raises(TypeError):
            t.function_with_vars(42, {})

        with pytest.raises(TypeError):
            t.function_with_vars("function", 42)
Beispiel #8
0
    def task(self, name):
        """
        Get a task from the task list by name. If the task name is not found,
        create a new task and insert it into the task list.

        :param name: name of task.
        :return: task specified.
        """
        if not isinstance(name, str):
            raise TypeError("task only accepts strings")

        t = _find_name_in_list(self._tasks, name)
        if t:
            return t

        t = Task(name)
        self._tasks.append(t)
        return t
Beispiel #9
0
    def test_invalid_function(self):
        t = Task("task 0")

        with pytest.raises(TypeError):
            t.dependency(42)
Beispiel #10
0
    def test_invalid_dependency(self):
        t = Task("task 0")

        with pytest.raises(TypeError):
            t.dependency("hello world")
Beispiel #11
0
    def test_invalid_commands(self):
        t = Task("task 0")

        with pytest.raises(TypeError):
            t.commands("hello world")
Beispiel #12
0
    def test_invalid_priority(self):
        t = Task("task 0")

        with pytest.raises(TypeError):
            t.priority("hello world")
Beispiel #13
0
 def test_invalid_name(self):
     with pytest.raises(TypeError):
         Task(42)