Ejemplo n.º 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"]
Ejemplo n.º 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"]
Ejemplo n.º 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"]
Ejemplo n.º 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"]
Ejemplo n.º 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"]
Ejemplo n.º 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"]
Ejemplo n.º 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)
Ejemplo n.º 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
Ejemplo n.º 9
0
    def test_invalid_function(self):
        t = Task("task 0")

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

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

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

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