Exemple #1
0
    def test_adding_tasks(self):
        tg = TaskGroup("task group 0")
        tg.task("task 0").tasks(["task 1", "task 2"])

        obj = tg.to_map()
        assert "task 0" in obj["tasks"]
        assert "task 1" in obj["tasks"]
        assert "task 2" in obj["tasks"]
Exemple #2
0
    def test_flat_value(self):
        tg = TaskGroup("task group 0")
        tg.max_hosts(5).timeout(42)

        obj = tg.to_map()
        assert "task group 0" == tg.get_name()
        assert "task group 0" == obj["name"]
        assert 5 == obj["max_hosts"]
        assert 42 == obj["timeout"]
Exemple #3
0
    def task_group(self, name):
        """
        Get a task group from the task group list by name. If the task group
        name is not found, create a new group task and insert it into the task
        group list.

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

        g = _find_name_in_list(self._groups, name)
        if g:
            return g

        g = TaskGroup(name)
        self._groups.append(g)
        return g
Exemple #4
0
    def test_invalid_tasks(self):
        tg = TaskGroup("task group 0")

        with pytest.raises(TypeError):
            tg.tasks("hello world")
Exemple #5
0
    def test_invalid_task(self):
        tg = TaskGroup("task group 0")

        with pytest.raises(TypeError):
            tg.task(42)
Exemple #6
0
 def test_invalid_name(self):
     with pytest.raises(TypeError):
         TaskGroup(42)
Exemple #7
0
    def test_teardown_group(self):
        tg = TaskGroup("task group 0")
        tg.teardown_group().function("func 0")

        obj = tg.to_map()
        assert "func 0" == obj["teardown_group"][0]["func"]
Exemple #8
0
    def test_setup_group(self):
        tg = TaskGroup("task group 0")
        tg.setup_group().function("func 0")

        obj = tg.to_map()
        assert "func 0" == obj["setup_group"][0]["func"]