chore(testrail): refactor init_testrail_api
Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
1d1a0b7d44
commit
ca984fa7a0
|
@ -7,7 +7,7 @@ from testrail_api import TestRailAPI
|
||||||
|
|
||||||
import configs
|
import configs
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
testrail_api = None
|
testrail_api = None
|
||||||
test_run_id = None
|
test_run_id = None
|
||||||
|
@ -22,37 +22,39 @@ test_case = namedtuple('TestCase', ['id', 'skipped'])
|
||||||
|
|
||||||
@pytest.fixture(scope='session')
|
@pytest.fixture(scope='session')
|
||||||
def init_testrail_api(request):
|
def init_testrail_api(request):
|
||||||
if configs.testrail.RUN_NAME:
|
if not configs.testrail.RUN_NAME:
|
||||||
_logger.info('TestRail API initializing')
|
LOG.info('TestRail report skipped')
|
||||||
global testrail_api
|
return
|
||||||
testrail_api = TestRailAPI(
|
|
||||||
configs.testrail.URL,
|
|
||||||
configs.testrail.USR,
|
|
||||||
configs.testrail.PSW
|
|
||||||
)
|
|
||||||
test_cases = get_test_cases_in_session(request)
|
|
||||||
test_run = get_test_run(configs.testrail.RUN_NAME)
|
|
||||||
if not test_run:
|
|
||||||
test_case_ids = list(set([tc_id.id for tc_id in test_cases]))
|
|
||||||
test_run = create_test_run(configs.testrail.RUN_NAME, test_case_ids)
|
|
||||||
|
|
||||||
global test_run_id
|
LOG.info('TestRail API initializing')
|
||||||
test_run_id = test_run['id']
|
global testrail_api
|
||||||
|
testrail_api = TestRailAPI(
|
||||||
|
configs.testrail.URL,
|
||||||
|
configs.testrail.USR,
|
||||||
|
configs.testrail.PSW
|
||||||
|
)
|
||||||
|
test_cases = get_test_cases_in_session(request)
|
||||||
|
test_run = get_test_run(configs.testrail.RUN_NAME)
|
||||||
|
if not test_run:
|
||||||
|
test_case_ids = list(set([tc_id.id for tc_id in test_cases]))
|
||||||
|
test_run = create_test_run(configs.testrail.RUN_NAME, test_case_ids)
|
||||||
|
|
||||||
for test_case in test_cases:
|
global test_run_id
|
||||||
if is_test_case_in_run(test_case.id):
|
test_run_id = test_run['id']
|
||||||
if test_case.skipped:
|
|
||||||
_update_result(test_case.id, SKIPPED, test_case.skipped)
|
for test_case in test_cases:
|
||||||
_logger.info(f'Test: "{test_case.id}" marked as "Skipped"')
|
if not is_test_case_in_run(test_case.id):
|
||||||
else:
|
LOG.info('Report result for test case: %s skipped, not in test run: %s',
|
||||||
if _get_test_case_status(test_case.id) != UNTESTED:
|
test_case.id, configs.testrail.RUN_NAME)
|
||||||
_update_result(test_case.id, UNTESTED)
|
continue
|
||||||
_logger.info(f'Test: "{test_case.id}" marked as "Untested"')
|
|
||||||
else:
|
if test_case.skipped:
|
||||||
_logger.info(
|
_update_result(test_case.id, SKIPPED, test_case.skipped)
|
||||||
f'Report result for test case: {test_case.id} skipped, not in test run: {configs.testrail.RUN_NAME}')
|
LOG.info(f'Test: "{test_case.id}" marked as "Skipped"')
|
||||||
else:
|
else:
|
||||||
_logger.info('TestRail report skipped')
|
if _get_test_case_status(test_case.id) != UNTESTED:
|
||||||
|
_update_result(test_case.id, UNTESTED)
|
||||||
|
LOG.info(f'Test: "{test_case.id}" marked as "Untested"')
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
|
Loading…
Reference in New Issue