From 1ead49af962d7d686dcd46ab34d0002394b346ed Mon Sep 17 00:00:00 2001 From: Joohyong Han Date: Tue, 19 Dec 2023 18:18:44 -0500 Subject: [PATCH 1/3] adding a function that returns test cases map --- src/dfcx_scrapi/core/test_cases.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/dfcx_scrapi/core/test_cases.py b/src/dfcx_scrapi/core/test_cases.py index b705a278..b1458f8c 100644 --- a/src/dfcx_scrapi/core/test_cases.py +++ b/src/dfcx_scrapi/core/test_cases.py @@ -570,6 +570,31 @@ def calculate_coverage(self, coverage_type: int, agent_id: str = None): response = client.calculate_coverage(request) return response + def get_test_cases_map(self, agent_id: str = None, reverse=False): + """Exports Agent Test Cases and UUIDs into a user friendly dict. + + Args: + agent_id: The agent to create the test case for. Format: + `projects//locations//agents/` + reverse: (Optional) Boolean flag to swap key:value -> value:key + Returns: + Dict containing Test Case UUIDs as keys and display names as values. + """ + if not agent_id: + agent_id = self.agent_id + + if reverse: + test_cases_dict = { + test_case.display_name: test_case.name + for test_case in self.list_test_cases(agent_id = agent_id) + } + else: + test_cases_dict = { + test_case.name: test_case.display_name + for test_case in self.list_test_cases(agent_id = agent_id) + } + return test_cases_dict + def get_test_case_results_df(self, agent_id=None, retest_all=False): """Convert Test Cases to Dataframe. From 5b2c16b8a1d93961f6f629cd0de65d4fadd73eef Mon Sep 17 00:00:00 2001 From: Joohyong Han Date: Tue, 19 Dec 2023 18:21:26 -0500 Subject: [PATCH 2/3] fixed bad indentation --- src/dfcx_scrapi/core/test_cases.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/dfcx_scrapi/core/test_cases.py b/src/dfcx_scrapi/core/test_cases.py index b1458f8c..8bb32cd7 100644 --- a/src/dfcx_scrapi/core/test_cases.py +++ b/src/dfcx_scrapi/core/test_cases.py @@ -584,15 +584,15 @@ def get_test_cases_map(self, agent_id: str = None, reverse=False): agent_id = self.agent_id if reverse: - test_cases_dict = { - test_case.display_name: test_case.name - for test_case in self.list_test_cases(agent_id = agent_id) - } + test_cases_dict = { + test_case.display_name: test_case.name + for test_case in self.list_test_cases(agent_id = agent_id) + } else: - test_cases_dict = { - test_case.name: test_case.display_name - for test_case in self.list_test_cases(agent_id = agent_id) - } + test_cases_dict = { + test_case.name: test_case.display_name + for test_case in self.list_test_cases(agent_id = agent_id) + } return test_cases_dict def get_test_case_results_df(self, agent_id=None, retest_all=False): From 7764778f6d4451975fb5e64fd701c496837c14d0 Mon Sep 17 00:00:00 2001 From: Milad <63479762+MRyderOC@users.noreply.github.com> Date: Wed, 20 Dec 2023 11:22:53 -0600 Subject: [PATCH 3/3] typo and lint fix --- src/dfcx_scrapi/core/test_cases.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/dfcx_scrapi/core/test_cases.py b/src/dfcx_scrapi/core/test_cases.py index 8bb32cd7..6d497f0e 100644 --- a/src/dfcx_scrapi/core/test_cases.py +++ b/src/dfcx_scrapi/core/test_cases.py @@ -574,9 +574,10 @@ def get_test_cases_map(self, agent_id: str = None, reverse=False): """Exports Agent Test Cases and UUIDs into a user friendly dict. Args: - agent_id: The agent to create the test case for. Format: - `projects//locations//agents/` + agent_id: The formatted CX Agent ID to use. Format: + `projects//locations//agents/` reverse: (Optional) Boolean flag to swap key:value -> value:key + Returns: Dict containing Test Case UUIDs as keys and display names as values. """ @@ -586,13 +587,14 @@ def get_test_cases_map(self, agent_id: str = None, reverse=False): if reverse: test_cases_dict = { test_case.display_name: test_case.name - for test_case in self.list_test_cases(agent_id = agent_id) + for test_case in self.list_test_cases(agent_id=agent_id) } else: test_cases_dict = { test_case.name: test_case.display_name - for test_case in self.list_test_cases(agent_id = agent_id) + for test_case in self.list_test_cases(agent_id=agent_id) } + return test_cases_dict def get_test_case_results_df(self, agent_id=None, retest_all=False):