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
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
testrail_api = None
|
||||
test_run_id = None
|
||||
|
@ -22,8 +22,11 @@ test_case = namedtuple('TestCase', ['id', 'skipped'])
|
|||
|
||||
@pytest.fixture(scope='session')
|
||||
def init_testrail_api(request):
|
||||
if configs.testrail.RUN_NAME:
|
||||
_logger.info('TestRail API initializing')
|
||||
if not configs.testrail.RUN_NAME:
|
||||
LOG.info('TestRail report skipped')
|
||||
return
|
||||
|
||||
LOG.info('TestRail API initializing')
|
||||
global testrail_api
|
||||
testrail_api = TestRailAPI(
|
||||
configs.testrail.URL,
|
||||
|
@ -40,19 +43,18 @@ def init_testrail_api(request):
|
|||
test_run_id = test_run['id']
|
||||
|
||||
for test_case in test_cases:
|
||||
if is_test_case_in_run(test_case.id):
|
||||
if not is_test_case_in_run(test_case.id):
|
||||
LOG.info('Report result for test case: %s skipped, not in test run: %s',
|
||||
test_case.id, configs.testrail.RUN_NAME)
|
||||
continue
|
||||
|
||||
if test_case.skipped:
|
||||
_update_result(test_case.id, SKIPPED, test_case.skipped)
|
||||
_logger.info(f'Test: "{test_case.id}" marked as "Skipped"')
|
||||
LOG.info(f'Test: "{test_case.id}" marked as "Skipped"')
|
||||
else:
|
||||
if _get_test_case_status(test_case.id) != UNTESTED:
|
||||
_update_result(test_case.id, UNTESTED)
|
||||
_logger.info(f'Test: "{test_case.id}" marked as "Untested"')
|
||||
else:
|
||||
_logger.info(
|
||||
f'Report result for test case: {test_case.id} skipped, not in test run: {configs.testrail.RUN_NAME}')
|
||||
else:
|
||||
_logger.info('TestRail report skipped')
|
||||
LOG.info(f'Test: "{test_case.id}" marked as "Untested"')
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
|
Loading…
Reference in New Issue