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

Fix robotframework2testrail.py to handle the new get_tests API #11

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
12 changes: 10 additions & 2 deletions robotframework2testrail.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,17 @@ def publish_results(api, testcases, run_id=0, plan_id=0, version='', publish_blo
"""
if run_id:
if api.is_testrun_available(run_id):
count = 0
logging.info('Publish in Test Run #%d', run_id)
testcases_in_testrun_list = api.get_tests(run_id)
test_offset = 0
tests_requested = 100
tests_left = True
testcases_in_testrun_list = []
while(tests_left):
testcases_from_testrail = api.get_tests(run_id, tests_requested, test_offset)
if (testcases_from_testrail['size'] == 0):
break
testcases_in_testrun_list += testcases_from_testrail['tests']
test_offset += (testcases_from_testrail['size'])

# Filter tests present in Test Run
case_id_in_testrun_list = [str(tc['case_id']) for tc in testcases_in_testrun_list]
Expand Down
13 changes: 8 additions & 5 deletions testrail_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
API_ADD_RESULT_CASES_URL = 'add_results_for_cases/{run_id}'
API_GET_RUN_URL = 'get_run/{run_id}'
API_GET_PLAN_URL = 'get_plan/{plan_id}'
API_GET_TESTS_URL = 'get_tests/{run_id}'
API_GET_TESTS_URL = 'get_tests/{run_id}&limit={limit}&offset={offset}'

ROBOTFWK_TO_TESTRAIL_STATUS = {
"PASS": 1,
"SKIP": 4,
"FAIL": 5,
}


class TestRailApiUtils(testrail.APIClient):
""" Class adding facilities to manipulate Testrail API """

Expand Down Expand Up @@ -131,13 +131,16 @@ def extract_testcase_id(str_content):

return testcase_id

def get_tests(self, testrun_id):
""" Return the list of tests containing in a Test Run.
def get_tests(self, testrun_id, testcase_limit, testcase_offset):
""" Return the list of tests containing in a Test Run,
starting at testcase_offset and returning max testcase_limit tests

:param testrun_id: TestRail ID of the Test Run
:param testcase_limit: max tests to return for request
:param testcase_offset: start offset for request

"""
try:
return self.send_get(API_GET_TESTS_URL.format(run_id=testrun_id))
return self.send_get(API_GET_TESTS_URL.format(run_id=testrun_id, limit=testcase_limit, offset=testcase_offset))
except testrail.APIError as error:
logging.error(error)