bbovenzi commented on code in PR #74365:
URL: https://github.com/apache/airflow/pull/74365#discussion_r4210844923
##########
airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_tasks.py:
##########
@@ -278,6 +279,50 @@ def test_should_respond_200_serialized(self, test_client,
testing_dag_bundle):
assert response.status_code == 200
assert response.json() == expected
+ def test_dag_version_id_describes_the_task_as_it_was(self, test_client,
dag_maker, session):
+ """A later edit must not change how an earlier version's task is
reported."""
+ dag_id = "test_versioned_task_dag"
+
+ # A new DagVersion is cut only when the serialized Dag changes under a
new bundle version,
+ # so each version is written the way the shared multi-version fixture
does it.
+ with dag_maker(dag_id, session=session, bundle_version="commit-one"):
+ EmptyOperator(task_id=self.task_id, retries=4)
+ session.commit()
+ first_version_id = str(DagVersion.get_version(dag_id,
session=session).id)
+
+ with dag_maker(dag_id, session=session, bundle_version="commit-two"):
+ EmptyOperator(task_id=self.task_id, retries=0)
+ session.commit()
+
+ assert str(DagVersion.get_version(dag_id, session=session).id) !=
first_version_id
+
+ test_client.app.dependency_overrides[dag_bag_from_app] = DBDagBag
+ url = f"{self.api_prefix}/{dag_id}/tasks/{self.task_id}"
+
+ latest = test_client.get(url)
+ assert latest.status_code == 200
+ assert latest.json()["retries"] == 0
+
+ pinned = test_client.get(url, params={"dag_version_id":
first_version_id})
+ assert pinned.status_code == 200
+ assert pinned.json()["retries"] == 4
+
+ def test_dag_version_id_of_another_dag_is_not_found(self, test_client,
testing_dag_bundle):
Review Comment:
Updated with a new
test`test_version_number_is_scoped_to_the_dag_in_the_path` that will 404 if the
version number doesnt exist on that dag
--
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]