-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <8822365+busunkim96@users.noreply.github.com> * Revised Code * fixed failing test * lint fix * lint fix * lint fix * Update samples/snippets/list_testcase_results.py Co-authored-by: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com> Co-authored-by: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com>
- Loading branch information
1 parent
04934ba
commit 50fda02
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |