Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_result_list():
iterable = [2, 3]
startAt = 0
maxResults = 50
total = 2
results = jira.client.ResultList(iterable, startAt, maxResults, total)
for idx, result in enumerate(results):
assert results[idx] == iterable[idx]
assert next(results) == iterable[0]
assert next(results) == iterable[1]
with pytest.raises(StopIteration):
next(results)
def test_result_list_if_empty():
results = jira.client.ResultList()
for r in results:
raise AssertionError("`results` should be empty")
with pytest.raises(StopIteration):
next(results)
if self._options['agile_rest_path'] == GreenHopperResource.GREENHOPPER_REST_PATH:
r_json = self._get_json('sprintquery/%s?includeHistoricSprints=true&includeFutureSprints=true' % board_id,
base=self.AGILE_BASE_URL)
if params:
warnings.warn('Old private GreenHopper API is used, parameters %s will be ignored.' % params, Warning)
if extended:
sprints = [Sprint(self._options, self._session, self.sprint_info(None, raw_sprints_json['id']))
for raw_sprints_json in r_json['sprints']]
else:
sprints = [Sprint(self._options, self._session, raw_sprints_json)
for raw_sprints_json in r_json['sprints']]
return ResultList(sprints, 0, len(sprints), len(sprints), True)
else:
return self._fetch_pages(Sprint, 'values', 'board/%s/sprint' % board_id, startAt, maxResults, params,
self.AGILE_BASE_URL)
page_size = max_results_from_response or len(items)
page_start = (startAt or start_at_from_response or 0) + page_size
while not is_last and (total is None or page_start < total) and len(next_items_page) == page_size:
page_params['startAt'] = page_start
page_params['maxResults'] = page_size
resource = self._get_json(request_path, params=page_params, base=base)
try:
next_items_page = [item_type(self._options, self._session, raw_issue_json) for raw_issue_json in
(resource[items_key] if items_key else resource)]
except KeyError as e:
e.message += " : " + json.dumps(resource)
raise
items.extend(next_items_page)
page_start += page_size
return ResultList(items, start_at_from_response, max_results_from_response, total, is_last)
else:
# it seams that search_users can return a list() containing a single user!
return ResultList([item_type(self._options, self._session, resource)], 0, 1, 1, True)
page_params['startAt'] = page_start
page_params['maxResults'] = page_size
resource = self._get_json(request_path, params=page_params, base=base)
try:
next_items_page = [item_type(self._options, self._session, raw_issue_json) for raw_issue_json in
(resource[items_key] if items_key else resource)]
except KeyError as e:
e.message += " : " + json.dumps(resource)
raise
items.extend(next_items_page)
page_start += page_size
return ResultList(items, start_at_from_response, max_results_from_response, total, is_last)
else:
# it seams that search_users can return a list() containing a single user!
return ResultList([item_type(self._options, self._session, resource)], 0, 1, 1, True)
"""
params = {}
if type:
params['type'] = type
if name:
params['name'] = name
if self._options['agile_rest_path'] == GreenHopperResource.GREENHOPPER_REST_PATH:
# Old, private API did not support pagination, all records were present in response,
# and no parameters were supported.
if startAt or maxResults or params:
warnings.warn('Old private GreenHopper API is used, all parameters will be ignored.', Warning)
r_json = self._get_json('rapidviews/list', base=self.AGILE_BASE_URL)
boards = [Board(self._options, self._session, raw_boards_json) for raw_boards_json in r_json['views']]
return ResultList(boards, 0, len(boards), len(boards), True)
else:
return self._fetch_pages(Board, 'values', 'board', startAt, maxResults, params, base=self.AGILE_BASE_URL)