Skip to content

Commit

Permalink
Add few tests on the mapped task group. (#36149)
Browse files Browse the repository at this point in the history
  • Loading branch information
avkirilishin committed Dec 30, 2023
1 parent 83bdc29 commit bed2789
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions tests/models/test_mappedoperator.py
Expand Up @@ -1568,3 +1568,62 @@ def my_teardown(val):
"tg_2.my_work": "skipped",
}
assert states == expected

def test_skip_one_mapped_task_from_task_group_with_generator(self, dag_maker):
with dag_maker() as dag:

@task
def make_list():
return [1, 2, 3]

@task
def double(n):
if n == 2:
raise AirflowSkipException()
return n * 2

@task
def last(n):
...

@task_group
def group(n: int) -> None:
last(double(n))

group.expand(n=make_list())

dr = dag.test()
states = self.get_states(dr)
expected = {
"group.double": {0: "success", 1: "skipped", 2: "success"},
"group.last": {0: "success", 1: "skipped", 2: "success"},
"make_list": "success",
}
assert states == expected

def test_skip_one_mapped_task_from_task_group(self, dag_maker):
with dag_maker() as dag:

@task
def double(n):
if n == 2:
raise AirflowSkipException()
return n * 2

@task
def last(n):
...

@task_group
def group(n: int) -> None:
last(double(n))

group.expand(n=[1, 2, 3])

dr = dag.test()
states = self.get_states(dr)
expected = {
"group.double": {0: "success", 1: "skipped", 2: "success"},
"group.last": {0: "success", 1: "skipped", 2: "success"},
}
assert states == expected

0 comments on commit bed2789

Please sign in to comment.