You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/11/26 06:15:20 UTC
[GitHub] [airflow] tirkarthi commented on a diff in pull request #27898: fix: current_state method on TaskInstance doesn't filter by map_index
tirkarthi commented on code in PR #27898:
URL: https://github.com/apache/airflow/pull/27898#discussion_r1032746090
##########
tests/cli/commands/test_task_command.py:
##########
@@ -420,6 +420,23 @@ def test_task_state(self):
)
)
+ def test_task_states_current_state(self):
Review Comment:
The patch looks correct to me but the test seems to pass without the patch. Can you please verify the test without patch? Below seems to be a better test without this being present in cli tests.
```diff
diff --git a/tests/models/test_taskinstance.py b/tests/models/test_taskinstance.py
index dd542666cd..78aea6ac72 100644
--- a/tests/models/test_taskinstance.py
+++ b/tests/models/test_taskinstance.py
@@ -1893,6 +1893,26 @@ class TestTaskInstance:
# check that no dataset events were generated
assert session.query(DatasetEvent).count() == 0
+ def test_mapped_current_state(self, dag_maker):
+ with dag_maker(dag_id="test_mapped_current_state") as dag:
+ from airflow.decorators import task
+
+ @task()
+ def divide_by(divisor):
+ return 1 / divisor
+
+ results = divide_by.expand(divisor=[0, 1])
+
+ tis = dag_maker.create_dagrun(execution_date=timezone.utcnow()).task_instances
+
+ with pytest.raises(ZeroDivisionError):
+ tis[0].run()
+
+ tis[1].run()
+
+ assert tis[0].current_state() == TaskInstanceState.FAILED
+ assert tis[1].current_state() == TaskInstanceState.SUCCESS
+
def test_changing_of_dataset_when_ddrq_is_already_populated(self, dag_maker, session):
"""
Test that when a task that produces dataset has ran, that changing the consumer
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org