11import uuid
2+ import pytest
3+ import os
24from concurrent .futures import ThreadPoolExecutor
35
46from temporalio .client import Client
@@ -24,10 +26,13 @@ def dynamic_system_prompt_test_model():
2426 )
2527
2628
27- async def test_execute_workflow_with_random_style (client : Client ):
29+ @pytest .mark .parametrize ("mock_model" , [True , False ])
30+ async def test_execute_workflow_with_random_style (client : Client , mock_model : bool ):
2831 task_queue_name = str (uuid .uuid4 ())
32+ if not mock_model and not os .environ .get ("OPENAI_API_KEY" ):
33+ pytest .skip (f"Skipping test (mock_model={ mock_model } ), because OPENAI_API_KEY is not set" )
2934
30- async with AgentEnvironment (model = dynamic_system_prompt_test_model ()) as agent_env :
35+ async with AgentEnvironment (model = dynamic_system_prompt_test_model () if mock_model else None ) as agent_env :
3136 client = agent_env .applied_on_client (client )
3237 async with Worker (
3338 client ,
@@ -48,10 +53,13 @@ async def test_execute_workflow_with_random_style(client: Client):
4853 assert any (style in result for style in ["haiku" , "pirate" , "robot" ])
4954
5055
51- async def test_execute_workflow_with_specific_style (client : Client ):
56+ @pytest .mark .parametrize ("mock_model" , [True , False ])
57+ async def test_execute_workflow_with_specific_style (client : Client , mock_model : bool ):
5258 task_queue_name = str (uuid .uuid4 ())
59+ if not mock_model and not os .environ .get ("OPENAI_API_KEY" ):
60+ pytest .skip (f"Skipping test (mock_model={ mock_model } ), because OPENAI_API_KEY is not set" )
5361
54- async with AgentEnvironment (model = dynamic_system_prompt_test_model ()) as agent_env :
62+ async with AgentEnvironment (model = dynamic_system_prompt_test_model () if mock_model else None ) as agent_env :
5563 client = agent_env .applied_on_client (client )
5664 async with Worker (
5765 client ,
0 commit comments