- Notifications
You must be signed in to change notification settings - Fork676
feat(api): add merge request pipeline manager and deprecate mr.pipelines() method#1323
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
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
29 changes: 25 additions & 4 deletionsdocs/gl_objects/mrs.rst
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
3 changes: 2 additions & 1 deletiongitlab/cli.py
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
21 changes: 2 additions & 19 deletionsgitlab/v4/objects/merge_requests.py
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
41 changes: 41 additions & 0 deletionsgitlab/v4/objects/pipelines.py
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
64 changes: 64 additions & 0 deletionstests/unit/objects/test_merge_request_pipelines.py
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
""" | ||
GitLab API: https://docs.gitlab.com/ee/api/merge_requests.html#list-mr-pipelines | ||
""" | ||
import pytest | ||
import responses | ||
from gitlab.v4.objects import ProjectMergeRequestPipeline | ||
pipeline_content = { | ||
"id": 1, | ||
"sha": "959e04d7c7a30600c894bd3c0cd0e1ce7f42c11d", | ||
"ref": "master", | ||
"status": "success", | ||
} | ||
@pytest.fixture() | ||
def resp_list_merge_request_pipelines(): | ||
with responses.RequestsMock() as rsps: | ||
rsps.add( | ||
method=responses.GET, | ||
url="http://localhost/api/v4/projects/1/merge_requests/1/pipelines", | ||
json=[pipeline_content], | ||
content_type="application/json", | ||
status=200, | ||
) | ||
yield rsps | ||
@pytest.fixture() | ||
def resp_create_merge_request_pipeline(): | ||
with responses.RequestsMock() as rsps: | ||
rsps.add( | ||
method=responses.POST, | ||
url="http://localhost/api/v4/projects/1/merge_requests/1/pipelines", | ||
json=pipeline_content, | ||
content_type="application/json", | ||
status=201, | ||
) | ||
yield rsps | ||
def test_merge_requests_pipelines_deprecated_raises_warning( | ||
project, resp_list_merge_request_pipelines | ||
): | ||
with pytest.deprecated_call(): | ||
pipelines = project.mergerequests.get(1, lazy=True).pipelines() | ||
assert len(pipelines) == 1 | ||
assert isinstance(pipelines[0], ProjectMergeRequestPipeline) | ||
assert pipelines[0].sha == pipeline_content["sha"] | ||
def test_list_merge_requests_pipelines(project, resp_list_merge_request_pipelines): | ||
pipelines = project.mergerequests.get(1, lazy=True).pipelines.list() | ||
assert len(pipelines) == 1 | ||
assert isinstance(pipelines[0], ProjectMergeRequestPipeline) | ||
assert pipelines[0].sha == pipeline_content["sha"] | ||
def test_create_merge_requests_pipelines(project, resp_create_merge_request_pipeline): | ||
pipeline = project.mergerequests.get(1, lazy=True).pipelines.create() | ||
assert isinstance(pipeline, ProjectMergeRequestPipeline) | ||
assert pipeline.sha == pipeline_content["sha"] |
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.