@@ -431,6 +431,79 @@ async def run(
431
431
#
432
432
433
433
434
+ async def test_sync_operation_happy_path (client : Client , env : WorkflowEnvironment ):
435
+ if env .supports_time_skipping :
436
+ pytest .skip ("Nexus tests don't work with time-skipping server" )
437
+ task_queue = str (uuid .uuid4 ())
438
+ async with Worker (
439
+ client ,
440
+ nexus_service_handlers = [ServiceImpl ()],
441
+ workflows = [CallerWorkflow , HandlerWorkflow ],
442
+ task_queue = task_queue ,
443
+ workflow_failure_exception_types = [Exception ],
444
+ ):
445
+ await create_nexus_endpoint (task_queue , client )
446
+ wf_output = await client .execute_workflow (
447
+ CallerWorkflow .run ,
448
+ args = [
449
+ CallerWfInput (
450
+ op_input = OpInput (
451
+ response_type = SyncResponse (
452
+ op_definition_type = OpDefinitionType .SHORTHAND ,
453
+ use_async_def = True ,
454
+ exception_in_operation_start = False ,
455
+ ),
456
+ headers = {},
457
+ caller_reference = CallerReference .IMPL_WITH_INTERFACE ,
458
+ ),
459
+ ),
460
+ False ,
461
+ task_queue ,
462
+ ],
463
+ id = str (uuid .uuid4 ()),
464
+ task_queue = task_queue ,
465
+ )
466
+ assert wf_output .op_output .value == "sync response"
467
+
468
+
469
+ async def test_workflow_run_operation_happy_path (
470
+ client : Client , env : WorkflowEnvironment
471
+ ):
472
+ if env .supports_time_skipping :
473
+ pytest .skip ("Nexus tests don't work with time-skipping server" )
474
+ task_queue = str (uuid .uuid4 ())
475
+ async with Worker (
476
+ client ,
477
+ nexus_service_handlers = [ServiceImpl ()],
478
+ workflows = [CallerWorkflow , HandlerWorkflow ],
479
+ task_queue = task_queue ,
480
+ workflow_failure_exception_types = [Exception ],
481
+ ):
482
+ await create_nexus_endpoint (task_queue , client )
483
+ wf_output = await client .execute_workflow (
484
+ CallerWorkflow .run ,
485
+ args = [
486
+ CallerWfInput (
487
+ op_input = OpInput (
488
+ response_type = AsyncResponse (
489
+ operation_workflow_id = str (uuid .uuid4 ()),
490
+ block_forever_waiting_for_cancellation = False ,
491
+ op_definition_type = OpDefinitionType .SHORTHAND ,
492
+ exception_in_operation_start = False ,
493
+ ),
494
+ headers = {},
495
+ caller_reference = CallerReference .IMPL_WITH_INTERFACE ,
496
+ ),
497
+ ),
498
+ False ,
499
+ task_queue ,
500
+ ],
501
+ id = str (uuid .uuid4 ()),
502
+ task_queue = task_queue ,
503
+ )
504
+ assert wf_output .op_output .value == "workflow result"
505
+
506
+
434
507
# TODO(nexus-preview): cross-namespace tests
435
508
# TODO(nexus-preview): nexus endpoint pytest fixture?
436
509
# TODO(nexus-prerelease): test headers
0 commit comments