ashb commented on code in PR #44692:
URL: https://github.com/apache/airflow/pull/44692#discussion_r1871201739
##########
tests/api_fastapi/execution_api/routes/test_task_instances.py:
##########
@@ -410,3 +411,81 @@ def test_ti_heartbeat_update(self, client, session,
create_task_instance, time_m
# If successful, ensure last_heartbeat_at is updated
session.refresh(ti)
assert ti.last_heartbeat_at == time_now.add(minutes=10)
+
+
+class TestTIPutRTIF:
+ def setup_method(self):
+ clear_db_runs()
+ clear_rendered_ti_fields()
+
+ def teardown_method(self):
+ clear_db_runs()
+ clear_rendered_ti_fields()
+
+ def test_ti_put_rtif_success(self, client, session, create_task_instance):
+ ti = create_task_instance(
+ task_id="test_ti_put_rtif_success",
+ state=State.RUNNING,
+ session=session,
+ )
+ session.commit()
+
+ payload = {"rendered_fields": {"field1": "rendered_value1", "field2":
"rendered_value2"}}
+
+ response = client.put(f"/execution/task-instances/{ti.id}/rtif",
json=payload)
+ assert response.status_code == 201
+ assert response.json() == {"message": "Rendered task instance fields
successfully set"}
+
+ session.expire_all()
+
+ rtifs = session.query(RenderedTaskInstanceFields).all()
+ assert len(rtifs) == 1
+
+ assert rtifs[0].task_id == "test_ti_put_rtif_success"
+ assert rtifs[0].rendered_fields == payload["rendered_fields"]
+
+ def test_ti_put_rtif_missing_ti(self, client, session,
create_task_instance):
+ create_task_instance(
+ task_id="test_ti_put_rtif_missing_ti",
+ state=State.RUNNING,
+ session=session,
+ )
+ session.commit()
+
+ payload = {"rendered_fields": {"field1": "rendered_value1", "field2":
"rendered_value2"}}
+
+ random_id = str(uuid6.uuid7())
Review Comment:
Nit: the str isn't needed since it's being used in a f-string
```suggestion
random_id = uuid6.uuid7()
```
--
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]