@@ -276,48 +276,49 @@ async def mock_build_request(workflow, args, options):
276276 assert captured_options .execution_start_to_close_timeout == timedelta (minutes = 30 )
277277
278278
279- class TestClientExecuteWorkflow :
280- """Test Client.execute_workflow method."""
279+ class TestClientStartWorkflow :
280+ """Test Client.start_workflow method."""
281281
282282 @pytest .mark .asyncio
283- async def test_execute_workflow_success (self , mock_client ):
284- """Test successful workflow execution ."""
285- # Mock start_workflow to return execution
283+ async def test_start_workflow_success (self , mock_client ):
284+ """Test successful workflow start ."""
285+ # Mock the gRPC stub
286286 execution = WorkflowExecution ()
287287 execution .workflow_id = "test-workflow-id"
288288 execution .run_id = "test-run-id"
289289
290+ response = StartWorkflowExecutionResponse ()
291+ response .run_id = "test-run-id"
292+
290293 client = Client (domain = "test-domain" , target = "localhost:7933" )
291- client .start_workflow = AsyncMock (return_value = execution )
294+ client ._workflow_stub = Mock ()
295+ client ._workflow_stub .StartWorkflowExecution = AsyncMock (return_value = response )
292296
293- result_execution = await client .execute_workflow (
297+ result_execution = await client .start_workflow (
294298 "TestWorkflow" ,
295299 "arg1" , "arg2" ,
296- task_list = "test-task-list"
300+ task_list = "test-task-list" ,
301+ workflow_id = "test-workflow-id"
297302 )
298303
299304 assert isinstance (result_execution , WorkflowExecution )
300- assert result_execution is execution
301305 assert result_execution .workflow_id == "test-workflow-id"
302306 assert result_execution .run_id == "test-run-id"
303307
304- # Verify start_workflow was called with correct arguments
305- client .start_workflow .assert_called_once_with (
306- "TestWorkflow" ,
307- "arg1" , "arg2" ,
308- task_list = "test-task-list"
309- )
308+ # Verify gRPC call was made
309+ client ._workflow_stub .StartWorkflowExecution .assert_called_once ()
310310
311311 @pytest .mark .asyncio
312- async def test_execute_workflow_propagates_error (self , mock_client ):
313- """Test that execute_workflow propagates errors from start_workflow ."""
312+ async def test_start_workflow_propagates_error (self , mock_client ):
313+ """Test that start_workflow propagates gRPC errors ."""
314314 client = Client (domain = "test-domain" , target = "localhost:7933" )
315- client .start_workflow = AsyncMock (side_effect = ValueError ("Invalid task_list" ))
315+ client ._workflow_stub = Mock ()
316+ client ._workflow_stub .StartWorkflowExecution = AsyncMock (side_effect = ValueError ("gRPC error" ))
316317
317- with pytest .raises (ValueError , match = "Invalid task_list " ):
318- await client .execute_workflow (
318+ with pytest .raises (Exception , match = "Failed to start workflow " ):
319+ await client .start_workflow (
319320 "TestWorkflow" ,
320- task_list = ""
321+ task_list = "valid-task-list "
321322 )
322323
323324
@@ -334,7 +335,7 @@ async def test_integration_workflow_invocation():
334335 client ._workflow_stub .StartWorkflowExecution = AsyncMock (return_value = response )
335336
336337 # Test the complete flow
337- execution = await client .execute_workflow (
338+ execution = await client .start_workflow (
338339 "IntegrationTestWorkflow" ,
339340 "test-arg" ,
340341 42 ,
0 commit comments