From 1a4772ddddc0a22a826b38c712b22c90d7c13598 Mon Sep 17 00:00:00 2001 From: Pankaj Kumar Bind Date: Sun, 20 Jul 2025 17:14:29 +0530 Subject: [PATCH 1/2] feat: Add missing tests for reject method --- tests/server/tasks/test_task_updater.py | 36 +++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/server/tasks/test_task_updater.py b/tests/server/tasks/test_task_updater.py index 1a633e6a7..812e97172 100644 --- a/tests/server/tasks/test_task_updater.py +++ b/tests/server/tasks/test_task_updater.py @@ -535,3 +535,39 @@ async def test_concurrent_updates_race_condition(event_queue): assert len(successes) == 1 assert len(failures) == 1 assert event_queue.enqueue_event.call_count == 1 + + +@pytest.mark.asyncio +async def test_reject_invalid_task_id(event_queue): + """Test rejecting a task with an invalid ID is handled gracefully.""" + pass + + +@pytest.mark.asyncio +async def test_reject_concurrently_with_complete(event_queue): + """Test for race conditions when reject and complete are called concurrently.""" + task_updater = TaskUpdater( + event_queue=event_queue, + task_id='concurrent-task', + context_id='concurrent-context', + ) + + tasks = [ + task_updater.reject(), + task_updater.complete(), + ] + + results = await asyncio.gather(*tasks, return_exceptions=True) + + successes = [r for r in results if not isinstance(r, Exception)] + failures = [r for r in results if isinstance(r, RuntimeError)] + + assert len(successes) == 1 + assert len(failures) == 1 + + assert event_queue.enqueue_event.call_count == 1 + + event = event_queue.enqueue_event.call_args[0][0] + assert isinstance(event, TaskStatusUpdateEvent) + assert event.final is True + assert event.status.state in [TaskState.rejected, TaskState.completed] From 0cd88079502d6591b5cce333efdc6ae293af0d40 Mon Sep 17 00:00:00 2001 From: Pankaj Kumar Bind Date: Sun, 20 Jul 2025 17:22:29 +0530 Subject: [PATCH 2/2] made changes suggested by gemini-code-assist --- tests/server/tasks/test_task_updater.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/server/tasks/test_task_updater.py b/tests/server/tasks/test_task_updater.py index 812e97172..e80328b29 100644 --- a/tests/server/tasks/test_task_updater.py +++ b/tests/server/tasks/test_task_updater.py @@ -537,12 +537,6 @@ async def test_concurrent_updates_race_condition(event_queue): assert event_queue.enqueue_event.call_count == 1 -@pytest.mark.asyncio -async def test_reject_invalid_task_id(event_queue): - """Test rejecting a task with an invalid ID is handled gracefully.""" - pass - - @pytest.mark.asyncio async def test_reject_concurrently_with_complete(event_queue): """Test for race conditions when reject and complete are called concurrently."""