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/03/11 16:42:02 UTC

[GitHub] [airflow] ashb commented on a change in pull request #22159: Use relation in TI join to RTIF

ashb commented on a change in pull request #22159:
URL: https://github.com/apache/airflow/pull/22159#discussion_r824888112



##########
File path: tests/api_connexion/endpoints/test_task_instance_endpoint.py
##########
@@ -293,6 +293,57 @@ def test_should_respond_200_task_instance_with_sla_and_rendered(self, session):
             "rendered_fields": {'op_args': [], 'op_kwargs': {}},
         }
 
+    def test_should_respond_200_mapped_task_instance_with_rtif(self, session):
+        """Verify we don't duplicate rows through join to RTIF"""
+        tis = self.create_task_instances(session)
+        session.query()
+        ti = tis[0]
+        ti.map_index = 1
+        rendered_fields = RTIF(ti, render_templates=False)
+        session.add(rendered_fields)
+        session.commit()
+        new_ti = TaskInstance(task=ti.task, run_id=ti.run_id, map_index=2)
+        for attr in ['duration', 'end_date', 'pid', 'start_date', 'state', 'queue']:
+            setattr(new_ti, attr, getattr(ti, attr))
+        session.add(new_ti)
+        rendered_fields = RTIF(new_ti, render_templates=False)
+        session.add(rendered_fields)
+        session.commit()
+
+        # in each loop, we should get the right mapped TI back
+        for map_index in (1, 2):
+            response = self.client.get(
+                f"/api/v1/dags/example_python_operator/dagRuns/TEST_DAG_RUN_ID/taskInstances/print_the_context/{map_index}",

Review comment:
       ```suggestion
                   f"/api/v1/dags/example_python_operator/dagRuns/TEST_DAG_RUN_ID/taskInstances"
                   + f"/print_the_context/{map_index}",
   ```




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