mirror of
https://github.com/status-im/status-mobile.git
synced 2025-02-09 07:13:46 +00:00
Changed adding TR results
This commit is contained in:
parent
5e9738bb7d
commit
9891469c6f
@ -1,13 +1,16 @@
|
|||||||
import json
|
|
||||||
import requests
|
|
||||||
import logging
|
|
||||||
import itertools
|
|
||||||
import emoji
|
|
||||||
import base64
|
import base64
|
||||||
from os import environ
|
import itertools
|
||||||
from support.base_test_report import BaseTestReport
|
import json
|
||||||
from sys import argv
|
import logging
|
||||||
|
import re
|
||||||
from json import JSONDecodeError
|
from json import JSONDecodeError
|
||||||
|
from os import environ
|
||||||
|
from sys import argv
|
||||||
|
|
||||||
|
import emoji
|
||||||
|
import requests
|
||||||
|
|
||||||
|
from support.base_test_report import BaseTestReport
|
||||||
|
|
||||||
|
|
||||||
class TestrailReport(BaseTestReport):
|
class TestrailReport(BaseTestReport):
|
||||||
@ -150,10 +153,11 @@ class TestrailReport(BaseTestReport):
|
|||||||
return case_ids
|
return case_ids
|
||||||
|
|
||||||
def add_results(self):
|
def add_results(self):
|
||||||
for test in self.get_all_tests():
|
data = list()
|
||||||
|
all_tests = self.get_all_tests()
|
||||||
|
for test in all_tests:
|
||||||
test_steps = "# Steps: \n"
|
test_steps = "# Steps: \n"
|
||||||
devices = str()
|
devices = str()
|
||||||
method = 'add_result_for_case/%s/%s' % (self.run_id, test.testrail_case_id)
|
|
||||||
last_testrun = test.testruns[-1]
|
last_testrun = test.testruns[-1]
|
||||||
for step in last_testrun.steps:
|
for step in last_testrun.steps:
|
||||||
test_steps += step + "\n"
|
test_steps += step + "\n"
|
||||||
@ -170,21 +174,36 @@ class TestrailReport(BaseTestReport):
|
|||||||
comment += '%s' % ('# Error: \n %s \n' % emoji.demojize(last_testrun.error)) + devices + test_steps
|
comment += '%s' % ('# Error: \n %s \n' % emoji.demojize(last_testrun.error)) + devices + test_steps
|
||||||
else:
|
else:
|
||||||
comment += devices + test_steps
|
comment += devices + test_steps
|
||||||
data = {'status_id': self.outcomes['undefined_fail'] if last_testrun.error else self.outcomes['passed'],
|
data.append(
|
||||||
'comment': comment}
|
{'case_id': test.testrail_case_id,
|
||||||
result = self.post(method, data=data)
|
'status_id': self.outcomes['undefined_fail'] if last_testrun.error else self.outcomes['passed'],
|
||||||
try:
|
'comment': comment})
|
||||||
result_id = result['id']
|
|
||||||
except KeyError:
|
results = self.post('add_results_for_cases/%s' % self.run_id, data={"results": data})
|
||||||
result_id = ''
|
try:
|
||||||
print("Got TestRail error when adding results for case %s: \n%s" % (test.testrail_case_id, result))
|
results[0]
|
||||||
|
except IndexError:
|
||||||
|
print("Got TestRail error when adding results: \n%s" % results)
|
||||||
|
|
||||||
|
for test in all_tests:
|
||||||
|
last_testrun = test.testruns[-1]
|
||||||
if last_testrun.error:
|
if last_testrun.error:
|
||||||
try:
|
try:
|
||||||
for geth in test.geth_paths.keys():
|
device = list(last_testrun.jobs.keys())[0]
|
||||||
self.add_attachment(method='add_attachment_to_result/%s' % str(result_id),
|
except IndexError:
|
||||||
path=test.geth_paths[geth])
|
continue
|
||||||
except AttributeError:
|
for res in results:
|
||||||
pass
|
if re.findall(r"%s\?auth=.*#%s" % (device, str(last_testrun.first_commands[device])),
|
||||||
|
res['comment']):
|
||||||
|
res_id = res['id']
|
||||||
|
try:
|
||||||
|
for geth in test.geth_paths.keys():
|
||||||
|
self.add_attachment(method='add_attachment_to_result/%s' % str(res_id),
|
||||||
|
path=test.geth_paths[geth])
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
|
break
|
||||||
|
|
||||||
self.change_test_run_description()
|
self.change_test_run_description()
|
||||||
|
|
||||||
def change_test_run_description(self):
|
def change_test_run_description(self):
|
||||||
|
@ -216,6 +216,16 @@ def should_save_device_stats(config):
|
|||||||
def pytest_runtest_makereport(item, call):
|
def pytest_runtest_makereport(item, call):
|
||||||
outcome = yield
|
outcome = yield
|
||||||
report = outcome.get_result()
|
report = outcome.get_result()
|
||||||
|
if "xdist_group" in item.keywords._markers and report.when == "setup" and report.failed:
|
||||||
|
test_suite_data.set_current_test(item.name, testrail_case_id=get_testrail_case_id(item))
|
||||||
|
test_suite_data.current_test.create_new_testrun()
|
||||||
|
test_suite_data.current_test.group_name = item.instance.__class__.__name__
|
||||||
|
error = report.longreprtext
|
||||||
|
exception = re.findall('E.*Message:|E.*Error:|E.*Failed:', error)
|
||||||
|
if exception:
|
||||||
|
error = error.replace(re.findall('E.*Message:|E.*Error:|E.*Failed:', report.longreprtext)[0], '')
|
||||||
|
test_suite_data.current_test.testruns[-1].error = "Test setup failed: \n" + error
|
||||||
|
github_report.save_test(test_suite_data.current_test)
|
||||||
if report.when == 'call':
|
if report.when == 'call':
|
||||||
is_sauce_env = item.config.getoption('env') == 'sauce'
|
is_sauce_env = item.config.getoption('env') == 'sauce'
|
||||||
current_test = test_suite_data.current_test
|
current_test = test_suite_data.current_test
|
||||||
|
@ -7,7 +7,7 @@ from support.api.third_parties_api import get_token_info
|
|||||||
|
|
||||||
|
|
||||||
def get_parameters():
|
def get_parameters():
|
||||||
directory = os.sep.join(__file__.split(os.sep)[:-4])
|
directory = os.sep.join(__file__.split(os.sep)[:-5])
|
||||||
file_path = path.join(directory, 'src/status_im/ethereum/tokens.cljs')
|
file_path = path.join(directory, 'src/status_im/ethereum/tokens.cljs')
|
||||||
with open(file_path, 'r') as f:
|
with open(file_path, 'r') as f:
|
||||||
data = f.read()
|
data = f.read()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user