Skip to content

Commit 1b0c458

Browse files
committed
[gitlab] Increase test coverage
This code increases the test coverage for the GitLab backend.
1 parent fb1a7fc commit 1b0c458

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

perceval/backends/core/gitlab.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class GitLab(Backend):
8181
:param sleep_time: time to sleep in case
8282
:param blacklist_ids: ids of items that must not be retrieved
8383
"""
84-
version = '0.7.0'
84+
version = '0.7.1'
8585

8686
CATEGORIES = [CATEGORY_ISSUE, CATEGORY_MERGE_REQUEST]
8787

@@ -350,7 +350,7 @@ def __get_note_award_emoji(self, item_type, item_id, note_id):
350350
emojis.append(emoji)
351351
except requests.exceptions.HTTPError as error:
352352
if error.response.status_code == 404:
353-
logger.warning("Emojis not available for %s ",
353+
logger.warning("Emojis not available for %s",
354354
urijoin(item_type, str(item_id), GitLabClient.NOTES,
355355
str(note_id), GitLabClient.EMOJI))
356356
return emojis

tests/test_gitlab.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@
6464
GITLAB_ENTERPRISE_MERGES_URL = GITLAB_ENTERPRISE_API_URL + "/projects/am%2Ftest/merge_requests"
6565

6666

67-
def setup_http_server(url_project, issues_url, merges_url, user_url, rate_limit_headers=None):
67+
def setup_http_server(url_project, issues_url, merges_url, user_url,
68+
rate_limit_headers=None, no_id_user=False,
69+
emojis_http_error=False):
6870
project = read_file('data/gitlab/project')
6971
page_issues_1 = read_file('data/gitlab/issue_page_1')
7072
page_issues_2 = read_file('data/gitlab/issue_page_2')
@@ -121,7 +123,11 @@ def setup_http_server(url_project, issues_url, merges_url, user_url, rate_limit_
121123
notes_1 = read_file('data/gitlab/notes_1')
122124
notes_2 = read_file('data/gitlab/notes_2')
123125
notes_3 = read_file('data/gitlab/notes_3')
124-
notes_4 = read_file('data/gitlab/notes_4')
126+
127+
if no_id_user:
128+
notes_4 = read_file('data/gitlab/notes_4_no_id_user')
129+
else:
130+
notes_4 = read_file('data/gitlab/notes_4')
125131

126132
# issue notes
127133
httpretty.register_uri(httpretty.GET,
@@ -271,11 +277,18 @@ def setup_http_server(url_project, issues_url, merges_url, user_url, rate_limit_
271277
status=200,
272278
forcing_headers=rate_limit_headers)
273279

274-
httpretty.register_uri(httpretty.GET,
275-
issues_url + "/1/notes/1/award_emoji",
276-
body=emoji,
277-
status=200,
278-
forcing_headers=rate_limit_headers)
280+
if emojis_http_error:
281+
httpretty.register_uri(httpretty.GET,
282+
issues_url + "/1/notes/1/award_emoji",
283+
body=emoji,
284+
status=404,
285+
forcing_headers=rate_limit_headers)
286+
else:
287+
httpretty.register_uri(httpretty.GET,
288+
issues_url + "/1/notes/1/award_emoji",
289+
body=emoji,
290+
status=200,
291+
forcing_headers=rate_limit_headers)
279292

280293
httpretty.register_uri(httpretty.GET,
281294
issues_url + "/1/notes/2/award_emoji",

0 commit comments

Comments
 (0)