diff --git a/testrail.py b/testrail.py index 6366c82..b131582 100644 --- a/testrail.py +++ b/testrail.py @@ -99,8 +99,10 @@ def data_pump(self, project='all', suite='all'): for project_ids in project_ids_list: projects_id = project_ids[0] + testrail_project_id = project_ids[1] suites = self.test_suites(testrail_project_id) + for suite in suites: """ print("testrail_project_id: {0}".format(testrail_project_id)) @@ -148,10 +150,10 @@ def testrail_coverage_update(self, projects_id, testrail_project_id, test_suite_id): # Pull JSON blob from Testrail - cases = self.test_cases(testrail_project_id, test_suite_id) + cases_metadata = self.test_cases(testrail_project_id, test_suite_id) # Format and store data in a data payload array - payload = self.db.report_test_coverage_payload(cases) + payload = self.db.report_test_coverage_payload(cases_metadata) print(payload) # Insert data in 'totals' array into DB @@ -201,15 +203,18 @@ def test_suites_update(self, testrail_project_id, self.session.add(suites) self.session.commit() - def report_test_coverage_payload(self, cases): + def report_test_coverage_payload(self, cases_metadata): """given testrail data (cases), calculate test case counts by type""" payload = [] + cases = cases_metadata['cases'] for case in cases: + row = [] suit = case['suite_id'] - subs = case['custom_sub_test_suites'] + subs = case.get("custom_sub_test_suites", [7]) + # TODO: diagnostic - delete print('suite_id: {0}, case_id: {1}, subs: {2}'.format(suit, case['id'], subs)) # noqa stat = case['custom_automation_status'] @@ -222,6 +227,7 @@ def report_test_coverage_payload(self, cases): row = [suit, sub, stat, cov, 1] payload.append(row) + df = pd.DataFrame(data=payload, columns=['suit', 'sub', 'status', 'cov', 'tally']) return df.groupby(['suit', 'sub', 'status', 'cov'])['tally'].sum().reset_index() # noqa