pierrejeambrun commented on code in PR #44986:
URL: https://github.com/apache/airflow/pull/44986#discussion_r1940999500
##########
tests/api_fastapi/execution_api/routes/test_task_instances.py:
##########
@@ -716,6 +716,81 @@ def test_ti_runtime_checks_failure(self, client, session,
create_task_instance):
session.expire_all()
+ def test_ti_update_state_to_fail_with_asset_profile_extra(self, client,
session, create_task_instance):
Review Comment:
You can just remove those tests.
The base class `StrictBaseModel` is tested. We would only need to check that
the actual datamodel extends the `StrictBaseModel`. I don't think we should
bother with that.
##########
tests/api_fastapi/execution_api/routes/test_task_instances.py:
##########
@@ -716,6 +716,81 @@ def test_ti_runtime_checks_failure(self, client, session,
create_task_instance):
session.expire_all()
+ def test_ti_update_state_to_fail_with_asset_profile_extra(self, client,
session, create_task_instance):
+ clear_db_assets()
+ clear_db_runs()
+
+ asset = AssetModel(
+ id=1,
+ name="s3://bucket/my-task",
+ uri="s3://bucket/my-task",
+ group="asset",
+ extra={},
+ )
+ asset_active = AssetActive.for_asset(asset)
+ session.add_all([asset, asset_active])
+
+ ti = create_task_instance(
+ task_id="test_ti_update_state_to_fail_with_extra",
+ start_date=DEFAULT_START_DATE,
+ state=State.RUNNING,
+ )
+ session.commit()
+
+ response = client.patch(
+ f"/execution/task-instances/{ti.id}/state",
+ json={
+ "state": "success",
+ "end_date": DEFAULT_END_DATE.isoformat(),
+ "task_outlets": [
+ {
+ "name": "s3://bucket/my-task",
+ "uri": "s3://bucket/my-task",
+ "asset_type": "Asset",
+ "foo": "bar",
+ }
+ ],
+ "outlet_events": {
+ "key": {"name": "s3://bucket/my-task", "uri":
"s3://bucket/my-task"},
+ "extra": {},
+ "asset_alias_events": [],
+ },
+ },
+ )
+
+ assert response.status_code == 422
+ assert response.json()["detail"][0]["msg"] == "Extra inputs are not
permitted"
+ session.expire_all()
+
+ def test_ti_update_state_to_fail_with_runtime_check_payload_with_extra(
+ self, client, session, create_task_instance
+ ):
+ ti = create_task_instance(
+
task_id="test_ti_update_state_to_fail_with_runtime_check_payload_with_extra",
+ state=State.RUNNING,
+ )
+ session.commit()
+
+ with mock.patch(
+
"airflow.models.taskinstance.TaskInstance.validate_inlet_outlet_assets_activeness"
+ ) as mock_validate_inlet_outlet_assets_activeness:
+ mock_validate_inlet_outlet_assets_activeness.side_effect = (
+
AirflowInactiveAssetInInletOrOutletException([AssetUniqueKey(name="abc",
uri="something")])
+ )
+ response = client.post(
+ f"/execution/task-instances/{ti.id}/runtime-checks",
+ json={
+ "inlets": [],
+ "outlets": [],
+ "foo": "bar",
+ },
+ )
+
+ assert response.status_code == 422
+ assert response.json()["detail"][0]["msg"] == "Extra inputs are
not permitted"
+
+ session.expire_all()
Review Comment:
same
##########
tests/api_fastapi/execution_api/routes/test_task_instances.py:
##########
@@ -716,6 +716,81 @@ def test_ti_runtime_checks_failure(self, client, session,
create_task_instance):
session.expire_all()
+ def test_ti_update_state_to_fail_with_asset_profile_extra(self, client,
session, create_task_instance):
+ clear_db_assets()
+ clear_db_runs()
Review Comment:
This is done in setup teardown, not needed I think.
##########
tests/api_fastapi/execution_api/routes/test_task_instances.py:
##########
@@ -716,6 +716,81 @@ def test_ti_runtime_checks_failure(self, client, session,
create_task_instance):
session.expire_all()
+ def test_ti_update_state_to_fail_with_asset_profile_extra(self, client,
session, create_task_instance):
+ clear_db_assets()
+ clear_db_runs()
+
+ asset = AssetModel(
+ id=1,
+ name="s3://bucket/my-task",
+ uri="s3://bucket/my-task",
+ group="asset",
+ extra={},
+ )
+ asset_active = AssetActive.for_asset(asset)
+ session.add_all([asset, asset_active])
+
+ ti = create_task_instance(
+ task_id="test_ti_update_state_to_fail_with_extra",
+ start_date=DEFAULT_START_DATE,
+ state=State.RUNNING,
+ )
+ session.commit()
+
+ response = client.patch(
+ f"/execution/task-instances/{ti.id}/state",
+ json={
+ "state": "success",
+ "end_date": DEFAULT_END_DATE.isoformat(),
+ "task_outlets": [
+ {
+ "name": "s3://bucket/my-task",
+ "uri": "s3://bucket/my-task",
+ "asset_type": "Asset",
+ "foo": "bar",
+ }
+ ],
+ "outlet_events": {
+ "key": {"name": "s3://bucket/my-task", "uri":
"s3://bucket/my-task"},
+ "extra": {},
+ "asset_alias_events": [],
+ },
+ },
+ )
+
+ assert response.status_code == 422
+ assert response.json()["detail"][0]["msg"] == "Extra inputs are not
permitted"
+ session.expire_all()
Review Comment:
Why expire_all ?
--
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]