|
64 | 64 | GITLAB_ENTERPRISE_MERGES_URL = GITLAB_ENTERPRISE_API_URL + "/projects/am%2Ftest/merge_requests" |
65 | 65 |
|
66 | 66 |
|
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): |
68 | 70 | project = read_file('data/gitlab/project') |
69 | 71 | page_issues_1 = read_file('data/gitlab/issue_page_1') |
70 | 72 | 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_ |
121 | 123 | notes_1 = read_file('data/gitlab/notes_1') |
122 | 124 | notes_2 = read_file('data/gitlab/notes_2') |
123 | 125 | 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') |
125 | 131 |
|
126 | 132 | # issue notes |
127 | 133 | httpretty.register_uri(httpretty.GET, |
@@ -271,11 +277,18 @@ def setup_http_server(url_project, issues_url, merges_url, user_url, rate_limit_ |
271 | 277 | status=200, |
272 | 278 | forcing_headers=rate_limit_headers) |
273 | 279 |
|
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) |
279 | 292 |
|
280 | 293 | httpretty.register_uri(httpretty.GET, |
281 | 294 | issues_url + "/1/notes/2/award_emoji", |
@@ -514,7 +527,7 @@ def test_fetch_issues_http_error_emojis(self): |
514 | 527 | def test_fetch_issues_blacklisted(self): |
515 | 528 | """Test whether blacklist issues are not fetched from GitLab""" |
516 | 529 |
|
517 | | - setup_http_server(GITLAB_URL_PROJECT, GITLAB_ISSUES_URL, |
| 530 | + setup_http_server(GITLAB_URL_PROJECT, GITLAB_ISSUES_URL, |
518 | 531 | GITLAB_MERGES_URL, GITLAB_USERS_URL) |
519 | 532 |
|
520 | 533 | gitlab = GitLab("fdroid", "fdroiddata", "your-token", blacklist_ids=[1, 2, 3]) |
@@ -585,7 +598,7 @@ def test_fetch_merges(self): |
585 | 598 | def test_fetch_merges_blacklisted(self): |
586 | 599 | """Test whether blacklist merge requests are not fetched from GitLab""" |
587 | 600 |
|
588 | | - setup_http_server(GITLAB_URL_PROJECT, GITLAB_ISSUES_URL, |
| 601 | + setup_http_server(GITLAB_URL_PROJECT, GITLAB_ISSUES_URL, |
589 | 602 | GITLAB_MERGES_URL, GITLAB_USERS_URL) |
590 | 603 |
|
591 | 604 | gitlab = GitLab("fdroid", "fdroiddata", "your-token", blacklist_ids=[1, 2]) |
|
0 commit comments