Skip to content
This repository has been archived by the owner on Jan 6, 2024. It is now read-only.

docs(samples): added filter sample #171

Merged
merged 13 commits into from Sep 22, 2021
41 changes: 41 additions & 0 deletions samples/snippets/list_testcase_results.py
@@ -0,0 +1,41 @@
# 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 = (
galz10 marked this conversation as resolved.
Show resolved Hide resolved
"projects/"
+ project_id
+ "/locations/"
+ location
+ "/agents/"
+ agent_id
+ "/testCases/"
+ test_id
)
req.filter = "environment=draft"
client = TestCasesClient(
client_options={"api_endpoint": "global-dialogflow.googleapis.com"}
)
result = client.list_test_case_results(request=req)
galz10 marked this conversation as resolved.
Show resolved Hide resolved
return result

# [END dialogflow_list_test_case_results_sample]
28 changes: 28 additions & 0 deletions samples/snippets/list_testcase_results_test.py
@@ -0,0 +1,28 @@
# 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 os

from list_testcase_results import list_test_case

LOCATION = 'global'
PROJECT_ID = os.getenv("GOOGLE_CLOUD_PROJECT")
galz10 marked this conversation as resolved.
Show resolved Hide resolved
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)