コード例 #1
0
ファイル: test_task.py プロジェクト: trahman1318/shrub.py
    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"]
コード例 #2
0
ファイル: test_task.py プロジェクト: trahman1318/shrub.py
    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"]
コード例 #3
0
ファイル: test_task.py プロジェクト: trahman1318/shrub.py
    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"]
コード例 #4
0
ファイル: test_task.py プロジェクト: trahman1318/shrub.py
    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"]
コード例 #5
0
ファイル: test_task.py プロジェクト: trahman1318/shrub.py
    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"]
コード例 #6
0
ファイル: test_task.py プロジェクト: trahman1318/shrub.py
    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"]
コード例 #7
0
ファイル: test_task.py プロジェクト: trahman1318/shrub.py
    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)
コード例 #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
コード例 #9
0
ファイル: test_task.py プロジェクト: trahman1318/shrub.py
    def test_invalid_function(self):
        t = Task("task 0")

        with pytest.raises(TypeError):
            t.dependency(42)
コード例 #10
0
ファイル: test_task.py プロジェクト: trahman1318/shrub.py
    def test_invalid_dependency(self):
        t = Task("task 0")

        with pytest.raises(TypeError):
            t.dependency("hello world")
コード例 #11
0
ファイル: test_task.py プロジェクト: trahman1318/shrub.py
    def test_invalid_commands(self):
        t = Task("task 0")

        with pytest.raises(TypeError):
            t.commands("hello world")
コード例 #12
0
ファイル: test_task.py プロジェクト: trahman1318/shrub.py
    def test_invalid_priority(self):
        t = Task("task 0")

        with pytest.raises(TypeError):
            t.priority("hello world")
コード例 #13
0
ファイル: test_task.py プロジェクト: trahman1318/shrub.py
 def test_invalid_name(self):
     with pytest.raises(TypeError):
         Task(42)