- Notifications
You must be signed in to change notification settings - Fork673
feat: add support for resource state events API#1364
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
Show all changes
4 commits Select commitHold shift + click to select a range
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
42 changes: 42 additions & 0 deletionsdocs/gl_objects/events.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -2,6 +2,9 @@ | ||
Events | ||
###### | ||
Events | ||
====== | ||
max-wittig marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
Reference | ||
--------- | ||
@@ -39,3 +42,42 @@ List the issue events on a project:: | ||
List the user events:: | ||
events = project.events.list() | ||
Resource state events | ||
===================== | ||
Reference | ||
--------- | ||
* v4 API: | ||
+ :class:`gitlab.v4.objects.ProjectIssueResourceStateEvent` | ||
+ :class:`gitlab.v4.objects.ProjectIssueResourceStateEventManager` | ||
+ :attr:`gitlab.v4.objects.ProjectIssue.resourcestateevents` | ||
+ :class:`gitlab.v4.objects.ProjectMergeRequestResourceStateEvent` | ||
+ :class:`gitlab.v4.objects.ProjectMergeRequestResourceStateEventManager` | ||
+ :attr:`gitlab.v4.objects.ProjectMergeRequest.resourcestateevents` | ||
* GitLab API: https://docs.gitlab.com/ee/api/resource_state_events.html | ||
Examples | ||
-------- | ||
You can list and get specific resource state events (via their id) for project issues | ||
and project merge requests. | ||
List the state events of a project issue (paginated):: | ||
state_events = issue.resourcestateevents.list() | ||
Get a specific state event of a project issue by its id:: | ||
state_event = issue.resourcestateevents.get(1) | ||
List the state events of a project merge request (paginated):: | ||
state_events = mr.resourcestateevents.list() | ||
Get a specific state event of a project merge request by its id:: | ||
state_event = mr.resourcestateevents.get(1) |
10 changes: 10 additions & 0 deletionsgitlab/tests/conftest.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
105 changes: 105 additions & 0 deletionsgitlab/tests/objects/test_resource_state_events.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,105 @@ | ||
""" | ||
GitLab API: https://docs.gitlab.com/ee/api/resource_state_events.html | ||
""" | ||
import pytest | ||
import responses | ||
from gitlab.v4.objects import ( | ||
ProjectIssueResourceStateEvent, | ||
ProjectMergeRequestResourceStateEvent, | ||
) | ||
issue_event_content = {"id": 1, "resource_type": "Issue"} | ||
mr_event_content = {"id": 1, "resource_type": "MergeRequest"} | ||
@pytest.fixture() | ||
def resp_list_project_issue_state_events(): | ||
with responses.RequestsMock() as rsps: | ||
rsps.add( | ||
method=responses.GET, | ||
url="http://localhost/api/v4/projects/1/issues/1/resource_state_events", | ||
json=[issue_event_content], | ||
content_type="application/json", | ||
status=200, | ||
) | ||
yield rsps | ||
@pytest.fixture() | ||
def resp_get_project_issue_state_event(): | ||
with responses.RequestsMock() as rsps: | ||
rsps.add( | ||
method=responses.GET, | ||
url="http://localhost/api/v4/projects/1/issues/1/resource_state_events/1", | ||
json=issue_event_content, | ||
content_type="application/json", | ||
status=200, | ||
) | ||
yield rsps | ||
@pytest.fixture() | ||
def resp_list_merge_request_state_events(): | ||
with responses.RequestsMock() as rsps: | ||
rsps.add( | ||
method=responses.GET, | ||
url="http://localhost/api/v4/projects/1/merge_requests/1/resource_state_events", | ||
json=[mr_event_content], | ||
content_type="application/json", | ||
status=200, | ||
) | ||
yield rsps | ||
@pytest.fixture() | ||
def resp_get_merge_request_state_event(): | ||
with responses.RequestsMock() as rsps: | ||
rsps.add( | ||
method=responses.GET, | ||
url="http://localhost/api/v4/projects/1/merge_requests/1/resource_state_events/1", | ||
json=mr_event_content, | ||
content_type="application/json", | ||
status=200, | ||
) | ||
yield rsps | ||
def test_list_project_issue_state_events( | ||
project_issue, resp_list_project_issue_state_events | ||
): | ||
state_events = project_issue.resourcestateevents.list() | ||
assert isinstance(state_events, list) | ||
state_event = state_events[0] | ||
assert isinstance(state_event, ProjectIssueResourceStateEvent) | ||
assert state_event.resource_type == "Issue" | ||
def test_get_project_issue_state_event( | ||
project_issue, resp_get_project_issue_state_event | ||
): | ||
state_event = project_issue.resourcestateevents.get(1) | ||
assert isinstance(state_event, ProjectIssueResourceStateEvent) | ||
assert state_event.resource_type == "Issue" | ||
def test_list_merge_request_state_events( | ||
project_merge_request, resp_list_merge_request_state_events | ||
): | ||
state_events = project_merge_request.resourcestateevents.list() | ||
assert isinstance(state_events, list) | ||
state_event = state_events[0] | ||
assert isinstance(state_event, ProjectMergeRequestResourceStateEvent) | ||
assert state_event.resource_type == "MergeRequest" | ||
def test_get_merge_request_state_event( | ||
project_merge_request, resp_get_merge_request_state_event | ||
): | ||
state_event = project_merge_request.resourcestateevents.get(1) | ||
assert isinstance(state_event, ProjectMergeRequestResourceStateEvent) | ||
assert state_event.resource_type == "MergeRequest" |
24 changes: 24 additions & 0 deletionsgitlab/v4/objects/events.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
2 changes: 2 additions & 0 deletionsgitlab/v4/objects/issues.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
2 changes: 2 additions & 0 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
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.