-
Notifications
You must be signed in to change notification settings - Fork 671
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
SachinKSingh28
wants to merge
1
commit into
python-gitlab:main
Choose a base branch
from
SachinKSingh28:fix/add-missing-status-check-methods
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The status update check is currently a no-op; use an assertion (e.g., assert response["status"] == "passed") to properly validate the response.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a typo in the variable name 'externa_status_check_id'; it should be 'external_status_check_id'.
Copilot uses AI. Check for mistakes.