+
+
+@pytest.mark.asyncio
+async def test_client_cache():
+ WFTemporal._client = None
+
+ with generate_mock_client() as client:
+ handle = Mock(WorkflowHandle)
+ handle.result = AsyncMock(return_value="success")
+ client.start_workflow.return_value = handle
+
+ temporal = WFTemporal()
+ result = await temporal.execute_workflow(
+ task_queue="q",
+ id="another id",
+ workflow_name="workflow-with-result",
+ workflow_data="data",
+ )
+ assert result == "success"
+ client.start_workflow.assert_awaited_once_with(
+ workflow="workflow-with-result", arg="data", id="another id", task_queue="q"
+ )
+
+ temporal = WFTemporal()
+ result = await temporal.execute_workflow(
+ task_queue="q",
+ id="yet another id",
+ workflow_name="workflow-with-result",
+ workflow_data="more data",
+ )
+ assert result == "success"
+ client.start_workflow.assert_awaited_with(
+ workflow="workflow-with-result",
+ arg="more data",
+ id="yet another id",
+ task_queue="q",
+ )