Skip to content

Commit

Permalink
Fixed Generator tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveMcGrath committed Aug 12, 2024
1 parent 5e6cee0 commit 0a2d3ca
Showing 1 changed file with 25 additions and 23 deletions.
48 changes: 25 additions & 23 deletions tests/jira/api/test_iterator.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@
def test_jira_get_iterator(jiraapi):
payload = {'test': 'value'}
test_response = {
'total': 2000,
'envelope': [{'id': i} for i in range(1000)],
'total': 200,
'envelope': [{'id': i} for i in range(100)],
}
test_response2 = {
'total': 2000,
'envelope': [{'id': i} for i in range(1000, 2000)],
'total': 200,
'envelope': [{'id': i} for i in range(100, 200)],
}
responses.get('https://nourl/rest/api/3/test',
json=test_response,
match=[query_param_matcher({
'test': 'value',
'startAt': 0,
'maxResults': 1000
'maxResults': 100
})]
)
responses.get('https://nourl/rest/api/3/test',
json=test_response2,
match=[query_param_matcher({
'test': 'value',
'startAt': 1000,
'maxResults': 1000
'startAt': 100,
'maxResults': 100
})]
)
iter_obj = JiraIterator(jiraapi,
Expand All @@ -45,27 +45,27 @@ def test_jira_get_iterator(jiraapi):
def test_jira_post_iterator(jiraapi):
payload = {'test': 'value'}
test_response = {
'total': 2000,
'envelope': [{'id': i} for i in range(1000)],
'total': 200,
'envelope': [{'id': i} for i in range(100)],
}
test_response2 = {
'total': 2000,
'envelope': [{'id': i} for i in range(1000, 2000)],
'total': 200,
'envelope': [{'id': i} for i in range(100, 200)],
}
responses.post('https://nourl/rest/api/3/test',
json=test_response,
match=[json_params_matcher({
'test': 'value',
'startAt': 0,
'maxResults': 1000
'maxResults': 100
})]
)
responses.post('https://nourl/rest/api/3/test',
json=test_response2,
match=[json_params_matcher({
'test': 'value',
'startAt': 1000,
'maxResults': 1000
'startAt': 100,
'maxResults': 100
})]
)
iter_obj = JiraIterator(jiraapi,
Expand All @@ -81,20 +81,20 @@ def test_jira_post_iterator(jiraapi):
@responses.activate
def test_search_generator(jiraapi):
test_response = {
'total': 2000,
'issues': [{'id': i} for i in range(1000)],
'total': 200,
'issues': [{'id': i} for i in range(100)],
}
test_response2 = {
'total': 2000,
'issues': [{'id': i} for i in range(1000, 2000)],
'total': 200,
'issues': [{'id': i} for i in range(100, 200)],
}
responses.post('https://nourl/rest/api/3/search',
json=test_response,
match=[json_params_matcher({
'jql': 'test jql search',
'expand': ['names'],
'fields': ['id'],
'maxResults': 1000,
'maxResults': 100,
'startAt': 0
})]
)
Expand All @@ -104,13 +104,15 @@ def test_search_generator(jiraapi):
'jql': 'test jql search',
'expand': ['names'],
'fields': ['id'],
'maxResults': 1000,
'startAt': 1000
'maxResults': 100,
'startAt': 100
})]
)
gen_obj = search_generator(api=jiraapi,
jql='test jql search',
fields=['id']
)
for page in gen_obj:
assert len(page) == 1000
for page, total, count in gen_obj:
assert len(page) == 100
assert total == 200
assert count < 3

0 comments on commit 0a2d3ca

Please sign in to comment.