Skip to content

Commit 50fda02

Browse files
galz10busunkim96
andauthored
docs(samples): added filter sample (#171)
* docs(samples): added filter sample * lint fix * removed pytest variables * update test id * Update samples/snippets/list_testcase_results_test.py Co-authored-by: Bu Sun Kim <[email protected]> * Revised Code * fixed failing test * lint fix * lint fix * lint fix * Update samples/snippets/list_testcase_results.py Co-authored-by: Bu Sun Kim <[email protected]> Co-authored-by: Bu Sun Kim <[email protected]>
1 parent 04934ba commit 50fda02

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Copyright 2021 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# [START dialogflow_list_test_case_results_sample]
16+
17+
from google.cloud.dialogflowcx_v3.services.test_cases.client import TestCasesClient
18+
from google.cloud.dialogflowcx_v3.types.test_case import ListTestCaseResultsRequest
19+
20+
21+
def list_test_case(project_id, agent_id, test_id, location):
22+
23+
req = ListTestCaseResultsRequest()
24+
req.parent = f"projects/{project_id}/locations/{location}/agents/{agent_id}/testCases/{test_id}"
25+
req.filter = "environment=draft"
26+
client = TestCasesClient(
27+
client_options={"api_endpoint": f"{location}-dialogflow.googleapis.com"}
28+
)
29+
# Makes a call to list all test case results that match filter
30+
result = client.list_test_case_results(request=req)
31+
print(result)
32+
return result
33+
34+
35+
# [END dialogflow_list_test_case_results_sample]
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Copyright 2021, Google LLC
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
15+
import google.auth
16+
17+
from list_testcase_results import list_test_case
18+
19+
LOCATION = "global"
20+
21+
_, PROJECT_ID = google.auth.default()
22+
AGENT_ID = "143dee60-56fe-4191-a8d8-095f569f6cd8"
23+
TEST_ID = "3c48d39e-71c0-4cb0-b974-3d5c596d347e"
24+
25+
26+
def test_list_testcase_results():
27+
result = list_test_case(PROJECT_ID, AGENT_ID, TEST_ID, LOCATION)
28+
29+
assert "Hello! How can I help you?" in str(result)

0 commit comments

Comments
 (0)