From 297072dea6be46befdd2d0ec2d86e34b1231e7ee Mon Sep 17 00:00:00 2001 From: Zhengfei Wang Date: Fri, 12 Apr 2024 00:16:39 +0800 Subject: [PATCH] add UT for PFS invocation failed --- .../tests/sdk_cli_test/unittests/test_trace.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/promptflow-devkit/tests/sdk_cli_test/unittests/test_trace.py b/src/promptflow-devkit/tests/sdk_cli_test/unittests/test_trace.py index cb61e72959b..ce021a6d723 100644 --- a/src/promptflow-devkit/tests/sdk_cli_test/unittests/test_trace.py +++ b/src/promptflow-devkit/tests/sdk_cli_test/unittests/test_trace.py @@ -30,6 +30,7 @@ TRACE_DEFAULT_COLLECTION, ContextAttributeKey, ) +from promptflow._sdk._errors import PromptFlowServiceInvokeError from promptflow._sdk._tracing import start_trace_with_devkit from promptflow._sdk.operations._trace_operations import TraceOperations from promptflow.client import PFClient @@ -197,6 +198,13 @@ def test_setup_exporter_in_executor_with_preview_flag( == f"http://localhost:{MOCK_PROMPTFLOW_SERVICE_PORT}/v1/traces" ) + def test_pfs_invocation_failed_in_start_trace(self): + with mock.patch("promptflow._sdk._tracing._invoke_pf_svc"), mock.patch( + "promptflow._sdk._tracing.is_pfs_service_healthy", return_value=False + ): + with pytest.raises(PromptFlowServiceInvokeError): + start_trace_with_devkit(collection=str(uuid.uuid4())) + @pytest.mark.unittest @pytest.mark.sdk_test