| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,6 +2,9 @@ | |||
| 2 | 2 | Events | |
| 3 | 3 | ###### | |
| 4 | 4 | ||
| 5 | + Events | ||
| 6 | + ====== | ||
| 7 | + | ||
| 5 | 8 | Reference | |
| 6 | 9 | --------- | |
| 7 | 10 | ||
@@ -39,3 +42,42 @@ List the issue events on a project:: | |||
| 39 | 42 | List the user events:: | |
| 40 | 43 | ||
| 41 | 44 | events = project.events.list() | |
| 45 | + | ||
| 46 | + Resource state events | ||
| 47 | + ===================== | ||
| 48 | + | ||
| 49 | + Reference | ||
| 50 | + --------- | ||
| 51 | + | ||
| 52 | + * v4 API: | ||
| 53 | + | ||
| 54 | + + :class:`gitlab.v4.objects.ProjectIssueResourceStateEvent` | ||
| 55 | + + :class:`gitlab.v4.objects.ProjectIssueResourceStateEventManager` | ||
| 56 | + + :attr:`gitlab.v4.objects.ProjectIssue.resourcestateevents` | ||
| 57 | + + :class:`gitlab.v4.objects.ProjectMergeRequestResourceStateEvent` | ||
| 58 | + + :class:`gitlab.v4.objects.ProjectMergeRequestResourceStateEventManager` | ||
| 59 | + + :attr:`gitlab.v4.objects.ProjectMergeRequest.resourcestateevents` | ||
| 60 | + | ||
| 61 | + * GitLab API: https://docs.gitlab.com/ee/api/resource_state_events.html | ||
| 62 | + | ||
| 63 | + Examples | ||
| 64 | + -------- | ||
| 65 | + | ||
| 66 | + You can list and get specific resource state events (via their id) for project issues | ||
| 67 | + and project merge requests. | ||
| 68 | + | ||
| 69 | + List the state events of a project issue (paginated):: | ||
| 70 | + | ||
| 71 | + state_events = issue.resourcestateevents.list() | ||
| 72 | + | ||
| 73 | + Get a specific state event of a project issue by its id:: | ||
| 74 | + | ||
| 75 | + state_event = issue.resourcestateevents.get(1) | ||
| 76 | + | ||
| 77 | + List the state events of a project merge request (paginated):: | ||
| 78 | + | ||
| 79 | + state_events = mr.resourcestateevents.list() | ||
| 80 | + | ||
| 81 | + Get a specific state event of a project merge request by its id:: | ||
| 82 | + | ||
| 83 | + state_event = mr.resourcestateevents.get(1) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -52,6 +52,16 @@ def project(gl): | |||
| 52 | 52 | return gl.projects.get(1, lazy=True) | |
| 53 | 53 | ||
| 54 | 54 | ||
| 55 | + @pytest.fixture | ||
| 56 | + def project_issue(project): | ||
| 57 | + return project.issues.get(1, lazy=True) | ||
| 58 | + | ||
| 59 | + | ||
| 60 | + @pytest.fixture | ||
| 61 | + def project_merge_request(project): | ||
| 62 | + return project.mergerequests.get(1, lazy=True) | ||
| 63 | + | ||
| 64 | + | ||
| 55 | 65 | @pytest.fixture | |
| 56 | 66 | def release(project, tag_name): | |
| 57 | 67 | return project.releases.get(tag_name, lazy=True) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,105 @@ | |||
| 1 | + """ | ||
| 2 | + GitLab API: https://docs.gitlab.com/ee/api/resource_state_events.html | ||
| 3 | + """ | ||
| 4 | + | ||
| 5 | + import pytest | ||
| 6 | + import responses | ||
| 7 | + | ||
| 8 | + from gitlab.v4.objects import ( | ||
| 9 | + ProjectIssueResourceStateEvent, | ||
| 10 | + ProjectMergeRequestResourceStateEvent, | ||
| 11 | + ) | ||
| 12 | + | ||
| 13 | + | ||
| 14 | + issue_event_content = {"id": 1, "resource_type": "Issue"} | ||
| 15 | + mr_event_content = {"id": 1, "resource_type": "MergeRequest"} | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + @pytest.fixture() | ||
| 19 | + def resp_list_project_issue_state_events(): | ||
| 20 | + with responses.RequestsMock() as rsps: | ||
| 21 | + rsps.add( | ||
| 22 | + method=responses.GET, | ||
| 23 | + url="http://localhost/api/v4/projects/1/issues/1/resource_state_events", | ||
| 24 | + json=[issue_event_content], | ||
| 25 | + content_type="application/json", | ||
| 26 | + status=200, | ||
| 27 | + ) | ||
| 28 | + yield rsps | ||
| 29 | + | ||
| 30 | + | ||
| 31 | + @pytest.fixture() | ||
| 32 | + def resp_get_project_issue_state_event(): | ||
| 33 | + with responses.RequestsMock() as rsps: | ||
| 34 | + rsps.add( | ||
| 35 | + method=responses.GET, | ||
| 36 | + url="http://localhost/api/v4/projects/1/issues/1/resource_state_events/1", | ||
| 37 | + json=issue_event_content, | ||
| 38 | + content_type="application/json", | ||
| 39 | + status=200, | ||
| 40 | + ) | ||
| 41 | + yield rsps | ||
| 42 | + | ||
| 43 | + | ||
| 44 | + @pytest.fixture() | ||
| 45 | + def resp_list_merge_request_state_events(): | ||
| 46 | + with responses.RequestsMock() as rsps: | ||
| 47 | + rsps.add( | ||
| 48 | + method=responses.GET, | ||
| 49 | + url="http://localhost/api/v4/projects/1/merge_requests/1/resource_state_events", | ||
| 50 | + json=[mr_event_content], | ||
| 51 | + content_type="application/json", | ||
| 52 | + status=200, | ||
| 53 | + ) | ||
| 54 | + yield rsps | ||
| 55 | + | ||
| 56 | + | ||
| 57 | + @pytest.fixture() | ||
| 58 | + def resp_get_merge_request_state_event(): | ||
| 59 | + with responses.RequestsMock() as rsps: | ||
| 60 | + rsps.add( | ||
| 61 | + method=responses.GET, | ||
| 62 | + url="http://localhost/api/v4/projects/1/merge_requests/1/resource_state_events/1", | ||
| 63 | + json=mr_event_content, | ||
| 64 | + content_type="application/json", | ||
| 65 | + status=200, | ||
| 66 | + ) | ||
| 67 | + yield rsps | ||
| 68 | + | ||
| 69 | + | ||
| 70 | + def test_list_project_issue_state_events( | ||
| 71 | + project_issue, resp_list_project_issue_state_events | ||
| 72 | + ): | ||
| 73 | + state_events = project_issue.resourcestateevents.list() | ||
| 74 | + assert isinstance(state_events, list) | ||
| 75 | + | ||
| 76 | + state_event = state_events[0] | ||
| 77 | + assert isinstance(state_event, ProjectIssueResourceStateEvent) | ||
| 78 | + assert state_event.resource_type == "Issue" | ||
| 79 | + | ||
| 80 | + | ||
| 81 | + def test_get_project_issue_state_event( | ||
| 82 | + project_issue, resp_get_project_issue_state_event | ||
| 83 | + ): | ||
| 84 | + state_event = project_issue.resourcestateevents.get(1) | ||
| 85 | + assert isinstance(state_event, ProjectIssueResourceStateEvent) | ||
| 86 | + assert state_event.resource_type == "Issue" | ||
| 87 | + | ||
| 88 | + | ||
| 89 | + def test_list_merge_request_state_events( | ||
| 90 | + project_merge_request, resp_list_merge_request_state_events | ||
| 91 | + ): | ||
| 92 | + state_events = project_merge_request.resourcestateevents.list() | ||
| 93 | + assert isinstance(state_events, list) | ||
| 94 | + | ||
| 95 | + state_event = state_events[0] | ||
| 96 | + assert isinstance(state_event, ProjectMergeRequestResourceStateEvent) | ||
| 97 | + assert state_event.resource_type == "MergeRequest" | ||
| 98 | + | ||
| 99 | + | ||
| 100 | + def test_get_merge_request_state_event( | ||
| 101 | + project_merge_request, resp_get_merge_request_state_event | ||
| 102 | + ): | ||
| 103 | + state_event = project_merge_request.resourcestateevents.get(1) | ||
| 104 | + assert isinstance(state_event, ProjectMergeRequestResourceStateEvent) | ||
| 105 | + assert state_event.resource_type == "MergeRequest" | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,10 +14,14 @@ | |||
| 14 | 14 | "ProjectIssueResourceLabelEventManager", | |
| 15 | 15 | "ProjectIssueResourceMilestoneEvent", | |
| 16 | 16 | "ProjectIssueResourceMilestoneEventManager", | |
| 17 | + "ProjectIssueResourceStateEvent", | ||
| 18 | + "ProjectIssueResourceStateEventManager", | ||
| 17 | 19 | "ProjectMergeRequestResourceLabelEvent", | |
| 18 | 20 | "ProjectMergeRequestResourceLabelEventManager", | |
| 19 | 21 | "ProjectMergeRequestResourceMilestoneEvent", | |
| 20 | 22 | "ProjectMergeRequestResourceMilestoneEventManager", | |
| 23 | + "ProjectMergeRequestResourceStateEvent", | ||
| 24 | + "ProjectMergeRequestResourceStateEventManager", | ||
| 21 | 25 | "UserEvent", | |
| 22 | 26 | "UserEventManager", | |
| 23 | 27 | ] | |
@@ -74,6 +78,16 @@ class ProjectIssueResourceMilestoneEventManager(RetrieveMixin, RESTManager): | |||
| 74 | 78 | _from_parent_attrs = {"project_id": "project_id", "issue_iid": "iid"} | |
| 75 | 79 | ||
| 76 | 80 | ||
| 81 | + class ProjectIssueResourceStateEvent(RESTObject): | ||
| 82 | + pass | ||
| 83 | + | ||
| 84 | + | ||
| 85 | + class ProjectIssueResourceStateEventManager(RetrieveMixin, RESTManager): | ||
| 86 | + _path = "/projects/%(project_id)s/issues/%(issue_iid)s/resource_state_events" | ||
| 87 | + _obj_cls = ProjectIssueResourceStateEvent | ||
| 88 | + _from_parent_attrs = {"project_id": "project_id", "issue_iid": "iid"} | ||
| 89 | + | ||
| 90 | + | ||
| 77 | 91 | class ProjectMergeRequestResourceLabelEvent(RESTObject): | |
| 78 | 92 | pass | |
| 79 | 93 | ||
@@ -98,6 +112,16 @@ class ProjectMergeRequestResourceMilestoneEventManager(RetrieveMixin, RESTManage | |||
| 98 | 112 | _from_parent_attrs = {"project_id": "project_id", "mr_iid": "iid"} | |
| 99 | 113 | ||
| 100 | 114 | ||
| 115 | + class ProjectMergeRequestResourceStateEvent(RESTObject): | ||
| 116 | + pass | ||
| 117 | + | ||
| 118 | + | ||
| 119 | + class ProjectMergeRequestResourceStateEventManager(RetrieveMixin, RESTManager): | ||
| 120 | + _path = "/projects/%(project_id)s/merge_requests/%(mr_iid)s/resource_state_events" | ||
| 121 | + _obj_cls = ProjectMergeRequestResourceStateEvent | ||
| 122 | + _from_parent_attrs = {"project_id": "project_id", "mr_iid": "iid"} | ||
| 123 | + | ||
| 124 | + | ||
| 101 | 125 | class UserEvent(Event): | |
| 102 | 126 | pass | |
| 103 | 127 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,6 +20,7 @@ | |||
| 20 | 20 | from .events import ( | |
| 21 | 21 | ProjectIssueResourceLabelEventManager, | |
| 22 | 22 | ProjectIssueResourceMilestoneEventManager, | |
| 23 | + ProjectIssueResourceStateEventManager, | ||
| 23 | 24 | ) | |
| 24 | 25 | from .notes import ProjectIssueNoteManager | |
| 25 | 26 | ||
@@ -110,6 +111,7 @@ class ProjectIssue( | |||
| 110 | 111 | ("notes", "ProjectIssueNoteManager"), | |
| 111 | 112 | ("resourcelabelevents", "ProjectIssueResourceLabelEventManager"), | |
| 112 | 113 | ("resourcemilestoneevents", "ProjectIssueResourceMilestoneEventManager"), | |
| 114 | + ("resourcestateevents", "ProjectIssueResourceStateEventManager"), | ||
| 113 | 115 | ) | |
| 114 | 116 | ||
| 115 | 117 | @cli.register_custom_action("ProjectIssue", ("to_project_id",)) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,6 +24,7 @@ | |||
| 24 | 24 | from .events import ( | |
| 25 | 25 | ProjectMergeRequestResourceLabelEventManager, | |
| 26 | 26 | ProjectMergeRequestResourceMilestoneEventManager, | |
| 27 | + ProjectMergeRequestResourceStateEventManager, | ||
| 27 | 28 | ) | |
| 28 | 29 | ||
| 29 | 30 | ||
@@ -121,6 +122,7 @@ class ProjectMergeRequest( | |||
| 121 | 122 | ("notes", "ProjectMergeRequestNoteManager"), | |
| 122 | 123 | ("resourcelabelevents", "ProjectMergeRequestResourceLabelEventManager"), | |
| 123 | 124 | ("resourcemilestoneevents", "ProjectMergeRequestResourceMilestoneEventManager"), | |
| 125 | + ("resourcestateevents", "ProjectMergeRequestResourceStateEventManager"), | ||
| 124 | 126 | ) | |
| 125 | 127 | ||
| 126 | 128 | @cli.register_custom_action("ProjectMergeRequest") | |
| Back | FazBrowse Home | New Git URL |
0 commit comments