Skip to content

Commit

Permalink
Merge pull request #30 from mozilla-mobile/irios-fixes-after-testrail…
Browse files Browse the repository at this point in the history
…-upgrade

Fixes to keep the scripts working after TestRail 7.5 upgrade
  • Loading branch information
isabelrios authored Apr 4, 2024
2 parents 621efaa + 4590778 commit b35714a
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions testrail.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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']
Expand All @@ -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
Expand Down

0 comments on commit b35714a

Please sign in to comment.