|
|
@ -16,13 +16,16 @@ |
|
|
|
# under the License. |
|
|
|
# under the License. |
|
|
|
|
|
|
|
|
|
|
|
"""Test Task class function.""" |
|
|
|
"""Test Task class function.""" |
|
|
|
|
|
|
|
import logging |
|
|
|
|
|
|
|
import re |
|
|
|
from unittest.mock import patch |
|
|
|
from unittest.mock import patch |
|
|
|
|
|
|
|
|
|
|
|
import pytest |
|
|
|
import pytest |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from pydolphinscheduler.core.process_definition import ProcessDefinition |
|
|
|
from pydolphinscheduler.core.task import Task, TaskRelation |
|
|
|
from pydolphinscheduler.core.task import Task, TaskRelation |
|
|
|
from tests.testing.task import Task as testTask |
|
|
|
from tests.testing.task import Task as testTask |
|
|
|
|
|
|
|
from tests.testing.task import TaskWithCode |
|
|
|
|
|
|
|
|
|
|
|
TEST_TASK_RELATION_SET = set() |
|
|
|
TEST_TASK_RELATION_SET = set() |
|
|
|
TEST_TASK_RELATION_SIZE = 0 |
|
|
|
TEST_TASK_RELATION_SIZE = 0 |
|
|
@ -222,3 +225,19 @@ def test_tasks_list_shift(dep_expr: str, flag: str): |
|
|
|
|
|
|
|
|
|
|
|
assert all([1 == len(getattr(t, reverse_direction_attr)) for t in tasks]) |
|
|
|
assert all([1 == len(getattr(t, reverse_direction_attr)) for t in tasks]) |
|
|
|
assert all([task.code in getattr(t, reverse_direction_attr) for t in tasks]) |
|
|
|
assert all([task.code in getattr(t, reverse_direction_attr) for t in tasks]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_add_duplicate(caplog): |
|
|
|
|
|
|
|
"""Test add task which code already in process definition.""" |
|
|
|
|
|
|
|
with ProcessDefinition("test_add_duplicate_workflow") as _: |
|
|
|
|
|
|
|
TaskWithCode(name="test_task_1", task_type="test", code=123, version=1) |
|
|
|
|
|
|
|
with caplog.at_level(logging.WARNING): |
|
|
|
|
|
|
|
TaskWithCode( |
|
|
|
|
|
|
|
name="test_task_duplicate_code", task_type="test", code=123, version=2 |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
assert all( |
|
|
|
|
|
|
|
[ |
|
|
|
|
|
|
|
caplog.text.startswith("WARNING pydolphinscheduler"), |
|
|
|
|
|
|
|
re.findall("already in process definition", caplog.text), |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
) |
|
|
|