2828from temporalio .exceptions import ApplicationError
2929from temporalio .testing import WorkflowEnvironment
3030from temporalio .worker import Worker , Replayer
31+ from temporalio .worker .workflow_sandbox import SandboxedWorkflowRunner , SandboxRestrictions
3132
3233from temporal_parseable import ParseablePlugin , ParseableConfig
3334from temporal_parseable ._emitter import ParseableEmitter
@@ -230,8 +231,16 @@ def make_interceptor_and_emitter():
230231 return interceptor , fake
231232
232233
234+ def _sandbox () -> SandboxedWorkflowRunner :
235+ """Sandbox with temporal_parseable as passthrough — mirrors ParseablePlugin behaviour."""
236+ return SandboxedWorkflowRunner (
237+ restrictions = SandboxRestrictions .default .with_passthrough_modules ("temporal_parseable" )
238+ )
239+
240+
233241# ── tests ─────────────────────────────────────────────────────────────────────
234242
243+ @pytest .mark .integration
235244@pytest .mark .asyncio
236245async def test_workflow_started_completed (env : WorkflowEnvironment ):
237246 interceptor , fake = make_interceptor_and_emitter ()
@@ -241,6 +250,7 @@ async def test_workflow_started_completed(env: WorkflowEnvironment):
241250 workflows = ALL_WORKFLOWS ,
242251 activities = ALL_ACTIVITIES ,
243252 interceptors = [interceptor ],
253+ workflow_runner = _sandbox (),
244254 ):
245255 await env .client .execute_workflow (
246256 SimpleWorkflow .run , "World" , id = "wf-1" , task_queue = "test"
@@ -254,6 +264,7 @@ async def test_workflow_started_completed(env: WorkflowEnvironment):
254264 assert wf_records [1 ]["workflow_name" ] == "SimpleWorkflow"
255265
256266
267+ @pytest .mark .integration
257268@pytest .mark .asyncio
258269async def test_activity_started_completed (env : WorkflowEnvironment ):
259270 interceptor , fake = make_interceptor_and_emitter ()
@@ -263,6 +274,7 @@ async def test_activity_started_completed(env: WorkflowEnvironment):
263274 workflows = ALL_WORKFLOWS ,
264275 activities = ALL_ACTIVITIES ,
265276 interceptors = [interceptor ],
277+ workflow_runner = _sandbox (),
266278 ):
267279 await env .client .execute_workflow (
268280 SimpleWorkflow .run , "World" , id = "wf-2" , task_queue = "test"
@@ -279,6 +291,7 @@ async def test_activity_started_completed(env: WorkflowEnvironment):
279291 assert "duration_ms" in completed
280292
281293
294+ @pytest .mark .integration
282295@pytest .mark .asyncio
283296async def test_activity_retries_and_failure (env : WorkflowEnvironment ):
284297 interceptor , fake = make_interceptor_and_emitter ()
@@ -288,6 +301,7 @@ async def test_activity_retries_and_failure(env: WorkflowEnvironment):
288301 workflows = ALL_WORKFLOWS ,
289302 activities = ALL_ACTIVITIES ,
290303 interceptors = [interceptor ],
304+ workflow_runner = _sandbox (),
291305 ):
292306 handle = await env .client .start_workflow (
293307 FailingActivityWorkflow .run ,
@@ -305,6 +319,7 @@ async def test_activity_retries_and_failure(env: WorkflowEnvironment):
305319 assert "error" in failed [0 ]
306320
307321
322+ @pytest .mark .integration
308323@pytest .mark .asyncio
309324async def test_signal_inbound (env : WorkflowEnvironment ):
310325 interceptor , fake = make_interceptor_and_emitter ()
@@ -314,6 +329,7 @@ async def test_signal_inbound(env: WorkflowEnvironment):
314329 workflows = ALL_WORKFLOWS ,
315330 activities = ALL_ACTIVITIES ,
316331 interceptors = [interceptor ],
332+ workflow_runner = _sandbox (),
317333 ):
318334 handle = await env .client .start_workflow (
319335 SignalWorkflow .run , id = "wf-signal" , task_queue = "test"
@@ -328,6 +344,7 @@ async def test_signal_inbound(env: WorkflowEnvironment):
328344 assert inbound [0 ]["status" ] == "started"
329345
330346
347+ @pytest .mark .integration
331348@pytest .mark .asyncio
332349async def test_query_inbound (env : WorkflowEnvironment ):
333350 interceptor , fake = make_interceptor_and_emitter ()
@@ -337,6 +354,7 @@ async def test_query_inbound(env: WorkflowEnvironment):
337354 workflows = ALL_WORKFLOWS ,
338355 activities = ALL_ACTIVITIES ,
339356 interceptors = [interceptor ],
357+ workflow_runner = _sandbox (),
340358 ):
341359 handle = await env .client .start_workflow (
342360 QueryWorkflow .run , id = "wf-query" , task_queue = "test"
@@ -349,6 +367,7 @@ async def test_query_inbound(env: WorkflowEnvironment):
349367 assert q_records [0 ]["message_name" ] == "get_value"
350368
351369
370+ @pytest .mark .integration
352371@pytest .mark .asyncio
353372async def test_update_inbound (env : WorkflowEnvironment ):
354373 interceptor , fake = make_interceptor_and_emitter ()
@@ -358,6 +377,7 @@ async def test_update_inbound(env: WorkflowEnvironment):
358377 workflows = ALL_WORKFLOWS ,
359378 activities = ALL_ACTIVITIES ,
360379 interceptors = [interceptor ],
380+ workflow_runner = _sandbox (),
361381 ):
362382 handle = await env .client .start_workflow (
363383 UpdateWorkflow .run , id = "wf-update" , task_queue = "test"
@@ -371,6 +391,7 @@ async def test_update_inbound(env: WorkflowEnvironment):
371391 assert any (r ["status" ] == "completed" for r in u_records )
372392
373393
394+ @pytest .mark .integration
374395@pytest .mark .asyncio
375396async def test_update_failure (env : WorkflowEnvironment ):
376397 interceptor , fake = make_interceptor_and_emitter ()
@@ -380,6 +401,7 @@ async def test_update_failure(env: WorkflowEnvironment):
380401 workflows = ALL_WORKFLOWS ,
381402 activities = ALL_ACTIVITIES ,
382403 interceptors = [interceptor ],
404+ workflow_runner = _sandbox (),
383405 ):
384406 handle = await env .client .start_workflow (
385407 UpdateWorkflow .run , id = "wf-update-fail" , task_queue = "test"
@@ -393,6 +415,7 @@ async def test_update_failure(env: WorkflowEnvironment):
393415 assert "error" in failed [0 ]
394416
395417
418+ @pytest .mark .integration
396419@pytest .mark .asyncio
397420async def test_user_events (env : WorkflowEnvironment ):
398421 interceptor , fake = make_interceptor_and_emitter ()
@@ -402,6 +425,7 @@ async def test_user_events(env: WorkflowEnvironment):
402425 workflows = ALL_WORKFLOWS ,
403426 activities = ALL_ACTIVITIES ,
404427 interceptors = [interceptor ],
428+ workflow_runner = _sandbox (),
405429 ):
406430 await env .client .execute_workflow (
407431 UserEventWorkflow .run , id = "wf-events" , task_queue = "test"
@@ -414,6 +438,7 @@ async def test_user_events(env: WorkflowEnvironment):
414438 assert "test.completed" in names
415439
416440
441+ @pytest .mark .integration
417442@pytest .mark .asyncio
418443async def test_child_workflow_outbound (env : WorkflowEnvironment ):
419444 interceptor , fake = make_interceptor_and_emitter ()
@@ -423,6 +448,7 @@ async def test_child_workflow_outbound(env: WorkflowEnvironment):
423448 workflows = ALL_WORKFLOWS ,
424449 activities = ALL_ACTIVITIES ,
425450 interceptors = [interceptor ],
451+ workflow_runner = _sandbox (),
426452 ):
427453 await env .client .execute_workflow (
428454 ChildWorkflowParent .run , "Alice" ,
@@ -437,6 +463,7 @@ async def test_child_workflow_outbound(env: WorkflowEnvironment):
437463 assert len (completed ) == 1
438464
439465
466+ @pytest .mark .integration
440467@pytest .mark .asyncio
441468async def test_continue_as_new_outbound (env : WorkflowEnvironment ):
442469 interceptor , fake = make_interceptor_and_emitter ()
@@ -446,6 +473,7 @@ async def test_continue_as_new_outbound(env: WorkflowEnvironment):
446473 workflows = ALL_WORKFLOWS ,
447474 activities = ALL_ACTIVITIES ,
448475 interceptors = [interceptor ],
476+ workflow_runner = _sandbox (),
449477 ):
450478 await env .client .execute_workflow (
451479 ContinueAsNewWorkflow .run , 1 ,
@@ -458,6 +486,7 @@ async def test_continue_as_new_outbound(env: WorkflowEnvironment):
458486 assert len (started ) >= 1
459487
460488
489+ @pytest .mark .integration
461490@pytest .mark .asyncio
462491async def test_replay_safety (env : WorkflowEnvironment ):
463492 """
@@ -476,6 +505,7 @@ async def test_replay_safety(env: WorkflowEnvironment):
476505 workflows = ALL_WORKFLOWS ,
477506 activities = ALL_ACTIVITIES ,
478507 interceptors = [interceptor ],
508+ workflow_runner = _sandbox (),
479509 ):
480510 await env .client .execute_workflow (
481511 SimpleWorkflow .run , "ReplayTest" ,
@@ -500,4 +530,4 @@ async def test_replay_safety(env: WorkflowEnvironment):
500530 assert len (replay_fake .records ) == 0 , (
501531 f"Replay emitted { len (replay_fake .records )} records but should emit 0. "
502532 f"Records: { replay_fake .records } "
503- )
533+ )
0 commit comments