Skip to content

Commit f9134fe

Browse files
committed
Activate nexus worker in worker tests
1 parent 6220334 commit f9134fe

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

tests/worker/test_worker.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
from typing import Any, Awaitable, Callable, Optional, Sequence
88
from urllib.request import urlopen
99

10+
import nexusrpc
11+
1012
import temporalio.api.enums.v1
11-
import temporalio.client
13+
import temporalio.nexus
1214
import temporalio.worker._worker
1315
from temporalio import activity, workflow
1416
from temporalio.api.workflowservice.v1 import (
@@ -80,6 +82,21 @@ async def run(self) -> None:
8082
raise NotImplementedError
8183

8284

85+
@nexusrpc.handler.service_handler
86+
class NeverRunService:
87+
@nexusrpc.handler.sync_operation
88+
async def never_run_operation(
89+
self, _ctx: nexusrpc.handler.StartOperationContext, _input: None
90+
) -> None:
91+
raise NotImplementedError
92+
93+
@temporalio.nexus.workflow_run_operation
94+
async def never_run_workflow_run_operation(
95+
self, _ctx: temporalio.nexus.WorkflowRunOperationContext, _input: None
96+
) -> temporalio.nexus.WorkflowHandle[None]:
97+
raise NotImplementedError
98+
99+
83100
async def test_worker_fatal_error_run(client: Client):
84101
# Run worker with injected workflow poll error
85102
worker = create_worker(client)
@@ -1143,6 +1160,7 @@ def create_worker(
11431160
task_queue=f"task-queue-{uuid.uuid4()}",
11441161
activities=[never_run_activity],
11451162
workflows=[NeverRunWorkflow],
1163+
nexus_service_handlers=[NeverRunService()],
11461164
on_fatal_error=on_fatal_error,
11471165
)
11481166

0 commit comments

Comments
 (0)