From 567a22355ac308ea64cd3804db09d9b0dcb286b3 Mon Sep 17 00:00:00 2001 From: Amogh Desai Date: Mon, 23 Dec 2024 18:07:06 +0530 Subject: [PATCH] Moving test that updates TI state to right class (#45173) --- .../routes/test_task_instances.py | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/tests/api_fastapi/execution_api/routes/test_task_instances.py b/tests/api_fastapi/execution_api/routes/test_task_instances.py index 4ed5f8f1598f3..b997a2e0ac88d 100644 --- a/tests/api_fastapi/execution_api/routes/test_task_instances.py +++ b/tests/api_fastapi/execution_api/routes/test_task_instances.py @@ -340,6 +340,33 @@ def test_ti_update_state_to_reschedule(self, client, session, create_task_instan assert trs[0].map_index == -1 assert trs[0].duration == 129600 + def test_ti_update_state_to_failed_table_check(self, client, session, create_task_instance): + ti = create_task_instance( + task_id="test_ti_update_state_to_failed_table_check", + state=State.RUNNING, + ) + ti.start_date = DEFAULT_START_DATE + session.commit() + + response = client.patch( + f"/execution/task-instances/{ti.id}/state", + json={ + "state": State.FAILED, + "end_date": DEFAULT_END_DATE.isoformat(), + }, + ) + + assert response.status_code == 204 + assert response.text == "" + + session.expire_all() + + ti = session.get(TaskInstance, ti.id) + assert ti.state == State.FAILED + assert ti.next_method is None + assert ti.next_kwargs is None + assert ti.duration == 3600.00 + class TestTIHealthEndpoint: def setup_method(self): @@ -509,33 +536,6 @@ def test_ti_heartbeat_update(self, client, session, create_task_instance, time_m session.refresh(ti) assert ti.last_heartbeat_at == time_now.add(minutes=10) - def test_ti_update_state_to_failed_table_check(self, client, session, create_task_instance): - ti = create_task_instance( - task_id="test_ti_update_state_to_failed_table_check", - state=State.RUNNING, - ) - ti.start_date = DEFAULT_START_DATE - session.commit() - - response = client.patch( - f"/execution/task-instances/{ti.id}/state", - json={ - "state": State.FAILED, - "end_date": DEFAULT_END_DATE.isoformat(), - }, - ) - - assert response.status_code == 204 - assert response.text == "" - - session.expire_all() - - ti = session.get(TaskInstance, ti.id) - assert ti.state == State.FAILED - assert ti.next_method is None - assert ti.next_kwargs is None - assert ti.duration == 3600.00 - class TestTIPutRTIF: def setup_method(self):