Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes to keep the scripts working after TestRail 7.5 upgrade #30

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

discussed with Isabel. Gonna land this now and later add an enum.
Note, this values, once defined in TestRail become a reference and won't be changing, hence we hard-code them here.

Example:
OTHER = 7
subs = case.get("custom_sub_test_suites", [OTHER])


# 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
Loading