sunank200 commented on code in PR #40084:
URL: https://github.com/apache/airflow/pull/40084#discussion_r1687938175


##########
tests/models/test_trigger.py:
##########
@@ -144,6 +151,58 @@ def test_submit_failure(session, create_task_instance):
     assert updated_task_instance.next_method == "__fail__"
 
 
[email protected](
+    "event_cls, expected",
+    [
+        (TaskSuccessEvent, "success"),
+        (TaskFailedEvent, "failed"),
+        (TaskSkippedEvent, "skipped"),
+    ],
+)
+def test_submit_event_task_end(session, create_task_instance, event_cls, 
expected):
+    """
+    Tests that events inheriting BaseTaskEndEvent *don't* re-wake their 
dependent
+    but mark them in the appropriate terminal state and send xcom
+    """
+    # Make a trigger
+    trigger = Trigger(classpath="does.not.matter", kwargs={})
+    trigger.id = 1
+    session.add(trigger)
+    session.commit()
+    # Make a TaskInstance that's deferred and waiting on it
+    task_instance = create_task_instance(
+        session=session, execution_date=timezone.utcnow(), state=State.DEFERRED
+    )
+    task_instance.trigger_id = trigger.id
+    session.commit()
+
+    def get_xcoms(ti):
+        return XCom.get_many(dag_ids=[ti.dag_id], task_ids=[ti.task_id], 
run_id=ti.run_id).all()
+
+    # now for the real test
+    # first check initial state
+    ti: TaskInstance = session.query(TaskInstance).one()
+    assert ti.state == "deferred"
+    assert get_xcoms(ti) == []
+
+    session.flush()
+    session.expunge_all()

Review Comment:
   Thanks I had missed this while testing.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to