Skip to content

Commit

Permalink
Merge pull request #159 from GoogleCloudPlatform/feature/get_test_cas…
Browse files Browse the repository at this point in the history
…es_map

Feature/get test cases map
  • Loading branch information
kmaphoenix authored Feb 8, 2024
2 parents 56c93f1 + 7764778 commit d13e3d2
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/dfcx_scrapi/core/test_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,33 @@ 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 formatted CX Agent ID to use. Format:
`projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>`
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.
Expand Down

0 comments on commit d13e3d2

Please sign in to comment.