Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix logical conflicts in PRs not found by CI #30095

Merged
merged 1 commit into from
Mar 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 26 additions & 6 deletions tests/decorators/test_setup_teardown.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

from airflow import AirflowException
from airflow.decorators import setup, task, task_group, teardown
from airflow.models.baseoperator import BaseOperator
from airflow.operators.bash import BashOperator
from airflow.utils.task_group import TaskGroup

Expand Down Expand Up @@ -276,7 +277,6 @@ def mytask2():

def test_setup_taskgroup_with_subgroup_being_the_setup_decorated(self, dag_maker):
"""Here, the subgroup is the setup taskgroup while the parent is not"""

with dag_maker() as dag:

@task_group
Expand All @@ -300,12 +300,16 @@ def mytask2():
mygroup()
assert len(dag.task_group.children) == 1
normal_task_group = dag.task_group.children["mygroup"]
assert isinstance(normal_task_group, TaskGroup)
assert len(normal_task_group.children) == 2
normal_task = normal_task_group.children["mygroup.mytask"]
assert not hasattr(normal_task, "_is_setup")
assert isinstance(normal_task, BaseOperator)
assert not normal_task._is_setup
setup_task_group = normal_task_group.children["mygroup.subgroup"]
assert isinstance(setup_task_group, TaskGroup)
assert len(setup_task_group.children) == 1
subgroup_task = setup_task_group.children["mygroup.subgroup.mytask2"]
assert isinstance(subgroup_task, BaseOperator)
assert subgroup_task._is_setup

def test_teardown_taskgroup_with_subgroup_being_the_teardown_decorated(self, dag_maker):
Expand Down Expand Up @@ -334,12 +338,16 @@ def mytask2():

assert len(dag.task_group.children) == 1
normal_task_group = dag.task_group.children["mygroup"]
assert isinstance(normal_task_group, TaskGroup)
assert len(normal_task_group.children) == 2
normal_task = normal_task_group.children["mygroup.mytask"]
assert not hasattr(normal_task, "_is_teardown")
assert isinstance(normal_task, BaseOperator)
assert not normal_task._is_teardown
teardown_task_group = normal_task_group.children["mygroup.subgroup"]
assert isinstance(teardown_task_group, TaskGroup)
assert len(teardown_task_group.children) == 1
subgroup_task = teardown_task_group.children["mygroup.subgroup.mytask2"]
assert isinstance(subgroup_task, BaseOperator)
assert subgroup_task._is_teardown

def test_setup_taskgroup_with_subgroup_being_the_setup_classic(self, dag_maker):
Expand All @@ -363,12 +371,16 @@ def mytask2():

assert len(dag.task_group.children) == 1
normal_task_group = dag.task_group.children["mygroup"]
assert isinstance(normal_task_group, TaskGroup)
assert len(normal_task_group.children) == 2
normal_task = normal_task_group.children["mygroup.mytask"]
assert not hasattr(normal_task, "_is_setup")
assert isinstance(normal_task, BaseOperator)
assert not normal_task._is_setup
setup_task_group = normal_task_group.children["mygroup.subgroup"]
assert isinstance(setup_task_group, TaskGroup)
assert len(setup_task_group.children) == 1
subgroup_task = setup_task_group.children["mygroup.subgroup.mytask2"]
assert isinstance(subgroup_task, BaseOperator)
assert subgroup_task._is_setup

def test_teardown_taskgroup_with_subgroup_being_the_teardown_classic(self, dag_maker):
Expand All @@ -392,12 +404,16 @@ def mytask2():

assert len(dag.task_group.children) == 1
normal_task_group = dag.task_group.children["mygroup"]
assert isinstance(normal_task_group, TaskGroup)
assert len(normal_task_group.children) == 2
normal_task = normal_task_group.children["mygroup.mytask"]
assert not hasattr(normal_task, "_is_teardown")
assert isinstance(normal_task, BaseOperator)
assert not normal_task._is_teardown
teardown_task_group = normal_task_group.children["mygroup.subgroup"]
assert isinstance(teardown_task_group, TaskGroup)
assert len(teardown_task_group.children) == 1
subgroup_task = teardown_task_group.children["mygroup.subgroup.mytask2"]
assert isinstance(subgroup_task, BaseOperator)
assert subgroup_task._is_teardown

def test_setup_taskgroup_using_alternative_syntax(self, dag_maker):
Expand All @@ -421,12 +437,16 @@ def mytask2():

assert len(dag.task_group.children) == 1
normal_task_group = dag.task_group.children["mygroup"]
assert isinstance(normal_task_group, TaskGroup)
assert len(normal_task_group.children) == 2
normal_task = normal_task_group.children["mygroup.mytask"]
assert not hasattr(normal_task, "_is_setup")
assert isinstance(normal_task, BaseOperator)
assert not normal_task._is_setup
setup_task_group = normal_task_group.children["mygroup.subgroup"]
assert isinstance(setup_task_group, TaskGroup)
assert len(setup_task_group.children) == 1
subgroup_task = setup_task_group.children["mygroup.subgroup.mytask2"]
assert isinstance(subgroup_task, BaseOperator)
assert subgroup_task._is_setup

def test_setup_teardown_are_mutually_exclusive_on_taskgroup(self, dag_maker):
Expand Down