- Notifications
You must be signed in to change notification settings - Fork675
fix: adds missing status check methods for merge requests#3128
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -24,11 +24,11 @@ Examples | ||||||
| List external status checks for a project:: | ||||||
| external_status_checks = project.external_status_checks.list() | ||||||
| Create an external status check with shared secret:: | ||||||
| external_status_checks = project.external_status_checks.create({ | ||||||
| "name": "mr_blocker", | ||||||
| "external_url": "https://example.com/mr-status-check", | ||||||
| "shared_secret": "secret-string" | ||||||
| @@ -38,7 +38,7 @@ Create an external status check with shared secret for protected branches:: | ||||||
| protected_branch = project.protectedbranches.get('main') | ||||||
| external_status_check = project.external_status_checks.create({ | ||||||
| "name": "mr_blocker", | ||||||
| "external_url": "https://example.com/mr-status-check", | ||||||
| "shared_secret": "secret-string", | ||||||
| @@ -48,10 +48,25 @@ Create an external status check with shared secret for protected branches:: | ||||||
| Update an external status check:: | ||||||
| external_status_check.external_url = "https://example.com/mr-blocker" | ||||||
| external_status_check.save() | ||||||
| Delete an external status check:: | ||||||
| external_status_check.delete(externa_status_check_id) | ||||||
CopilotAI | ||||||
| external_status_check.delete(externa_status_check_id) | |
| external_status_check.delete(external_status_check_id) |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -5,6 +5,49 @@ | ||||||
| import pytest | ||||||
| import responses | ||||||
| mr_content = { | ||||||
| "id": 1, | ||||||
| "iid": 1, | ||||||
| "project_id": 1, | ||||||
| "title": "test1", | ||||||
| "description": "fixed login page css paddings", | ||||||
| "state": "merged", | ||||||
| "sha": "somerandomstring", | ||||||
| "merged_by": { | ||||||
| "id": 87854, | ||||||
| "name": "Douwe Maan", | ||||||
| "username": "DouweM", | ||||||
| "state": "active", | ||||||
| "avatar_url": "https://gitlab.example.com/uploads/-/system/user/avatar/87854/avatar.png", | ||||||
| "web_url": "https://gitlab.com/DouweM", | ||||||
| }, | ||||||
| "reviewers": [ | ||||||
| { | ||||||
| "id": 2, | ||||||
| "name": "Sam Bauch", | ||||||
| "username": "kenyatta_oconnell", | ||||||
| "state": "active", | ||||||
| "avatar_url": "https://www.gravatar.com/avatar/956c92487c6f6f7616b536927e22c9a0?s=80&d=identicon", | ||||||
| "web_url": "http://gitlab.example.com//kenyatta_oconnell", | ||||||
| } | ||||||
| ], | ||||||
| } | ||||||
| external_status_checks_content = [ | ||||||
| { | ||||||
| "id": 2, | ||||||
| "name": "Service 2", | ||||||
| "external_url": "https://gitlab.example.com/test-endpoint-2", | ||||||
| "status": "pending", | ||||||
| }, | ||||||
| { | ||||||
| "id": 1, | ||||||
| "name": "Service 1", | ||||||
| "external_url": "https://gitlab.example.com/test-endpoint-1", | ||||||
| "status": "pending", | ||||||
| }, | ||||||
| ] | ||||||
| @pytest.fixture | ||||||
| def external_status_check(): | ||||||
| @@ -104,6 +147,54 @@ def resp_delete_external_status_checks(): | ||||||
| content_type="application/json", | ||||||
| status=200, | ||||||
| ) | ||||||
| yield rsps | ||||||
| @pytest.fixture | ||||||
| def resp_list_merge_requests_status_checks(): | ||||||
| with responses.RequestsMock() as rsps: | ||||||
| rsps.add( | ||||||
| method=responses.GET, | ||||||
| url="http://localhost/api/v4/projects/1/merge_requests/1", | ||||||
| json=mr_content, | ||||||
| content_type="application/json", | ||||||
| status=200, | ||||||
| ) | ||||||
| rsps.add( | ||||||
| method=responses.GET, | ||||||
| url="http://localhost/api/v4/projects/1/merge_requests/1/status_checks", | ||||||
| json=external_status_checks_content, | ||||||
| content_type="application/json", | ||||||
| status=200, | ||||||
| ) | ||||||
| yield rsps | ||||||
| @pytest.fixture | ||||||
| def resp_list_merge_requests_status_checks_set_value(): | ||||||
| with responses.RequestsMock() as rsps: | ||||||
| rsps.add( | ||||||
| method=responses.GET, | ||||||
| url="http://localhost/api/v4/projects/1/merge_requests/1", | ||||||
| json=mr_content, | ||||||
| content_type="application/json", | ||||||
| status=200, | ||||||
| ) | ||||||
| rsps.add( | ||||||
| method=responses.GET, | ||||||
| url="http://localhost/api/v4/projects/1/merge_requests/1/status_checks", | ||||||
| json=external_status_checks_content, | ||||||
| content_type="application/json", | ||||||
| status=200, | ||||||
| ) | ||||||
| rsps.add( | ||||||
| method=responses.POST, | ||||||
| url="http://localhost/api/v4/projects/1/merge_requests/1/status_check_responses", | ||||||
| json={"status": "passed"}, | ||||||
| content_type="application/json", | ||||||
| status=200, | ||||||
| ) | ||||||
| yield rsps | ||||||
| @@ -125,3 +216,30 @@ def test_delete_external_status_checks(gl, resp_delete_external_status_checks): | ||||||
| gl.projects.get(1, lazy=True).external_status_checks.delete(1) | ||||||
| status_checks = gl.projects.get(1, lazy=True).external_status_checks.list() | ||||||
| assert len(status_checks) == 0 | ||||||
| def test_get_merge_request_external_status_checks( | ||||||
| gl, resp_list_merge_requests_status_checks | ||||||
| ): | ||||||
| merge_request = gl.projects.get(1, lazy=True).mergerequests.get(1) | ||||||
| external_status_checks = merge_request.external_status_checks.list() | ||||||
| assert len(external_status_checks) == 2 | ||||||
| def test_get_merge_request_external_status_checks_set_value( | ||||||
| gl, resp_list_merge_requests_status_checks_set_value | ||||||
| ): | ||||||
| merge_request = gl.projects.get(1, lazy=True).mergerequests.get(1) | ||||||
| external_status_checks = merge_request.external_status_checks.list() | ||||||
| assert len(external_status_checks) == 2 | ||||||
| for external_status_check in external_status_checks: | ||||||
| if external_status_check.name == "Service 2": | ||||||
| response = merge_request.external_status_check_response.update( | ||||||
| { | ||||||
| "external_status_check_id": external_status_check.id, | ||||||
| "status": "passed", | ||||||
| "sha": merge_request.sha, | ||||||
| } | ||||||
| ) | ||||||
| response["status"] == "passed" | ||||||
CopilotAI | ||||||
| response["status"]=="passed" | |
| assertresponse["status"]=="passed" |
Uh oh!
There was an error while loading.Please reload this page.