Changed run name and TestRail report for PRs
Signed-off-by: yevh-berdnyk <ie.berdnyk@gmail.com>
This commit is contained in:
parent
f2b8ccce2a
commit
75d612cb98
|
@ -47,6 +47,16 @@ class TestrailReport(BaseTestReport):
|
|||
def get_milestones(self):
|
||||
return self.get('get_milestones/%s' % self.project_id)
|
||||
|
||||
def get_runs(self, pr_number):
|
||||
return [i for i in self.get('get_runs/%s' % self.project_id) if 'PR-%s ' % pr_number in i['name']]
|
||||
|
||||
def get_run(self, run_id: int):
|
||||
return self.get('get_run/%s' % run_id)
|
||||
|
||||
def get_last_pr_run(self, pr_number):
|
||||
run_id = max([run['id'] for run in self.get_runs(pr_number)])
|
||||
return self.get_run(run_id=run_id)
|
||||
|
||||
@property
|
||||
def actual_milestone_id(self):
|
||||
return self.get_milestones()[-1]['id']
|
||||
|
@ -55,7 +65,7 @@ class TestrailReport(BaseTestReport):
|
|||
request_body = {'suite_id': self.suite_id,
|
||||
'name': run_name,
|
||||
'milestone_id': self.actual_milestone_id,
|
||||
'case_ids': self.get_regression_cases(),
|
||||
'case_ids': self.get_regression_cases(is_pr='PR-' in run_name),
|
||||
'include_all': False}
|
||||
run = self.post('add_run/%s' % self.project_id, request_body)
|
||||
self.run_id = run['id']
|
||||
|
@ -63,7 +73,7 @@ class TestrailReport(BaseTestReport):
|
|||
def get_cases(self, section_id):
|
||||
return self.get('get_cases/%s&suite_id=%s§ion_id=%s' % (self.project_id, self.suite_id, section_id))
|
||||
|
||||
def get_regression_cases(self):
|
||||
def get_regression_cases(self, is_pr=False):
|
||||
test_cases = dict()
|
||||
test_cases['smoke_phase_1'] = 157
|
||||
test_cases['smoke_phase_2'] = 308
|
||||
|
@ -71,6 +81,9 @@ class TestrailReport(BaseTestReport):
|
|||
test_cases['error_handling'] = 458
|
||||
test_cases['logcat_verifications'] = 718
|
||||
case_ids = list()
|
||||
if is_pr:
|
||||
case_ids = [case['id'] for case in self.get_cases(test_cases['smoke_phase_1'])]
|
||||
else:
|
||||
for phase in test_cases:
|
||||
for case in self.get_cases(test_cases[phase]):
|
||||
case_ids.append(case['id'])
|
||||
|
|
|
@ -101,7 +101,13 @@ def pytest_configure(config):
|
|||
if '.apk' in i]])[0]
|
||||
if is_master(config):
|
||||
if config.getoption('testrail_report'):
|
||||
testrail_report.add_run(test_suite_data.apk_name)
|
||||
pr_number = config.getoption('pr_number')
|
||||
if pr_number:
|
||||
run_number = len(testrail_report.get_runs(pr_number)) + 1
|
||||
run_name = 'PR-%s run #%s' % (pr_number, run_number)
|
||||
else:
|
||||
run_name = test_suite_data.apk_name
|
||||
testrail_report.add_run(run_name)
|
||||
if config.getoption('env') == 'sauce':
|
||||
if not is_uploaded():
|
||||
if 'http' in config.getoption('apk'):
|
||||
|
|
Loading…
Reference in New Issue