diff --git a/samples/snippets/list_testcase_results.py b/samples/snippets/list_testcase_results.py new file mode 100644 index 00000000..ef26b3f8 --- /dev/null +++ b/samples/snippets/list_testcase_results.py @@ -0,0 +1,35 @@ +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# [START dialogflow_list_test_case_results_sample] + +from google.cloud.dialogflowcx_v3.services.test_cases.client import TestCasesClient +from google.cloud.dialogflowcx_v3.types.test_case import ListTestCaseResultsRequest + + +def list_test_case(project_id, agent_id, test_id, location): + + req = ListTestCaseResultsRequest() + req.parent = f"projects/{project_id}/locations/{location}/agents/{agent_id}/testCases/{test_id}" + req.filter = "environment=draft" + client = TestCasesClient( + client_options={"api_endpoint": f"{location}-dialogflow.googleapis.com"} + ) + # Makes a call to list all test case results that match filter + result = client.list_test_case_results(request=req) + print(result) + return result + + +# [END dialogflow_list_test_case_results_sample] diff --git a/samples/snippets/list_testcase_results_test.py b/samples/snippets/list_testcase_results_test.py new file mode 100644 index 00000000..e4d534f7 --- /dev/null +++ b/samples/snippets/list_testcase_results_test.py @@ -0,0 +1,29 @@ +# Copyright 2021, Google LLC +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +import google.auth + +from list_testcase_results import list_test_case + +LOCATION = "global" + +_, PROJECT_ID = google.auth.default() +AGENT_ID = "143dee60-56fe-4191-a8d8-095f569f6cd8" +TEST_ID = "3c48d39e-71c0-4cb0-b974-3d5c596d347e" + + +def test_list_testcase_results(): + result = list_test_case(PROJECT_ID, AGENT_ID, TEST_ID, LOCATION) + + assert "Hello! How can I help you?" in str(result)