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

Commit

Permalink
docs(samples): added filter sample (#171)
Browse files Browse the repository at this point in the history
* 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
galz10 and busunkim96 committed Sep 22, 2021
1 parent 63851ae commit 5b7e6b9
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
35 changes: 35 additions & 0 deletions 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]
29 changes: 29 additions & 0 deletions 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)

0 comments on commit 5b7e6b9

Please sign in to comment.