@@ -89,9 +89,9 @@ class NonSerializableOutput:
89
89
class MyService :
90
90
echo : nexusrpc .Operation [Input , Output ]
91
91
# TODO(nexus-prerelease): support renamed operations!
92
- # echo_renamed: nexusrpc.Operation[Input, Output] = (
93
- # nexusrpc.Operation( name="echo-renamed")
94
- # )
92
+ echo_renamed : nexusrpc .Operation [Input , Output ] = nexusrpc . Operation (
93
+ name = "echo-renamed"
94
+ )
95
95
hang : nexusrpc .Operation [Input , Output ]
96
96
log : nexusrpc .Operation [Input , Output ]
97
97
workflow_run_operation_happy_path : nexusrpc .Operation [Input , Output ]
@@ -147,6 +147,17 @@ async def echo(self, ctx: StartOperationContext, input: Input) -> Output:
147
147
value = f"from start method on { self .__class__ .__name__ } : { input .value } "
148
148
)
149
149
150
+ # The name override is prsent in the service definition. But the test below submits
151
+ # the same operation name in the request whether using a service definition or now.
152
+ # The name override here is necessary when the test is not using the service
153
+ # definition. It should be permitted when the service definition is in effect, as
154
+ # long as the name override is the same as that in the service definition.
155
+ # TODO(nexus-prerelease): implement in nexusrpc the check that operation handler
156
+ # name overrides must be consistent with service definition overrides.
157
+ @sync_operation (name = "echo-renamed" )
158
+ async def echo_renamed (self , ctx : StartOperationContext , input : Input ) -> Output :
159
+ return await self .echo (ctx , input )
160
+
150
161
@sync_operation
151
162
async def hang (self , ctx : StartOperationContext , input : Input ) -> Output :
152
163
await asyncio .Future ()
@@ -467,13 +478,8 @@ class SyncHandlerHappyPath(_TestCase):
467
478
), "Nexus-Link header not echoed correctly."
468
479
469
480
470
- class SyncHandlerHappyPathRenamed (_TestCase ):
481
+ class SyncHandlerHappyPathRenamed (SyncHandlerHappyPath ):
471
482
operation = "echo-renamed"
472
- input = Input ("hello" )
473
- expected = SuccessfulResponse (
474
- status_code = 200 ,
475
- body_json = {"value" : "from start method on MyServiceHandler: hello" },
476
- )
477
483
478
484
479
485
class SyncHandlerHappyPathNonAsyncDef (_TestCase ):
@@ -707,8 +713,7 @@ class NonSerializableOutputFailure(_FailureTestCase):
707
713
"test_case" ,
708
714
[
709
715
SyncHandlerHappyPath ,
710
- # TODO(nexus-prerelease): support renamed operations!
711
- # SyncHandlerHappyPathRenamed,
716
+ SyncHandlerHappyPathRenamed ,
712
717
SyncHandlerHappyPathNonAsyncDef ,
713
718
# TODO(nexus-prerelease): make callable instance work
714
719
# SyncHandlerHappyPathWithNonAsyncCallableInstance,
0 commit comments