jroachgolf84 commented on code in PR #73135:
URL: https://github.com/apache/airflow/pull/73135#discussion_r4200638517


##########
airflow-core/tests/unit/jobs/test_triggerer_job.py:
##########
@@ -1033,6 +1043,254 @@ async def 
test_create_triggers_asset_state_store_accessor_reads_and_writes(
     await runner.cleanup_finished_triggers()
 
 
[email protected]
+def make_deferred_trigger():
+    """Factory fixture: call with a list to get a BaseTrigger subclass that 
appends each new instance."""
+
+    def factory(injected_instances):
+        class DeferredTrigger(BaseTrigger):
+            def __init__(self, **kwargs):
+                super().__init__(**kwargs)
+                injected_instances.append(self)
+
+            def serialize(self):
+                return (f"{type(self).__module__}.{type(self).__qualname__}", 
{})
+
+            async def run(self):
+                yield TriggerEvent("done")
+
+        return DeferredTrigger
+
+    return factory
+
+
+def _ti_dto(map_index=-1):
+    return TaskInstanceDTO(
+        id=uuid.uuid4(),
+        dag_version_id=uuid.uuid4(),
+        task_id="my_task",
+        dag_id="test_dag",
+        run_id="test_run",
+        try_number=1,
+        map_index=map_index,
+        pool_slots=1,
+        queue="default",
+        priority_weight=1,
+    )
+
+
+def test_task_instance_dto_rejects_a_null_map_index():
+    """If the map_index is None, it should raise an error (it should be -1)."""
+    with pytest.raises(ValidationError):
+        _ti_dto(map_index=None)
+
+
[email protected]
[email protected]("map_index", [-1, 3], ids=["unmapped", "mapped"])
+@patch("airflow.jobs.triggerer_job_runner.TriggerRunner.get_trigger_by_classpath")
+async def 
test_create_triggers_injects_task_state_store_scoped_to_the_deferring_ti(
+    mock_get_classpath, session, make_deferred_trigger, map_index
+):
+    """task_state_store is populated, and scoped to the task instance that 
deferred."""

Review Comment:
   Resolved locally.



-- 
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