Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit194ee01

Browse files
nejchJohnVillalovos
authored andcommitted
feat: add support for iterations API
1 parent66461ba commit194ee01

File tree

7 files changed

+112
-0
lines changed

7 files changed

+112
-0
lines changed

‎docs/api-objects.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ API examples
2828
gl_objects/group_access_tokens
2929
gl_objects/invitations
3030
gl_objects/issues
31+
gl_objects/iterations
3132
gl_objects/keys
3233
gl_objects/boards
3334
gl_objects/labels

‎docs/gl_objects/iterations.rst

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
##########
2+
Iterations
3+
##########
4+
5+
6+
Reference
7+
---------
8+
9+
* v4 API:
10+
11+
+:class:`gitlab.v4.objects.GroupIteration`
12+
+:class:`gitlab.v4.objects.GroupIterationManager`
13+
+:attr:`gitlab.v4.objects.Group.iterations`
14+
+:class:`gitlab.v4.objects.ProjectIterationManager`
15+
+:attr:`gitlab.v4.objects.Project.iterations`
16+
17+
* GitLab API: https://docs.gitlab.com/ee/api/iterations.html
18+
19+
Examples
20+
--------
21+
22+
..note::
23+
24+
GitLab no longer has project iterations. Using a project endpoint returns
25+
the ancestor groups' iterations.
26+
27+
List iterations for a project's ancestor groups::
28+
29+
iterations = project.iterations.list()
30+
31+
List iterations for a group::
32+
33+
iterations = group.iterations.list()

‎gitlab/v4/objects/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
from .integrationsimport*
4848
from .invitationsimport*
4949
from .issuesimport*
50+
from .iterationsimport*
5051
from .jobsimport*
5152
from .keysimport*
5253
from .labelsimport*

‎gitlab/v4/objects/groups.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from .hooksimportGroupHookManager# noqa: F401
2525
from .invitationsimportGroupInvitationManager# noqa: F401
2626
from .issuesimportGroupIssueManager# noqa: F401
27+
from .iterationsimportGroupIterationManager# noqa: F401
2728
from .labelsimportGroupLabelManager# noqa: F401
2829
from .membersimport (# noqa: F401
2930
GroupBillableMemberManager,
@@ -71,6 +72,7 @@ class Group(SaveMixin, ObjectDeleteMixin, RESTObject):
7172
invitations:GroupInvitationManager
7273
issues:GroupIssueManager
7374
issues_statistics:GroupIssuesStatisticsManager
75+
iterations:GroupIterationManager
7476
labels:GroupLabelManager
7577
members:GroupMemberManager
7678
members_all:GroupMemberAllManager

‎gitlab/v4/objects/iterations.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
fromgitlab.baseimportRESTManager,RESTObject
2+
fromgitlab.mixinsimportListMixin
3+
4+
__all__= [
5+
"ProjectIterationManager",
6+
"GroupIteration",
7+
"GroupIterationManager",
8+
]
9+
10+
11+
classGroupIteration(RESTObject):
12+
_repr_attr="title"
13+
14+
15+
classGroupIterationManager(ListMixin,RESTManager):
16+
_path="/groups/{group_id}/iterations"
17+
_obj_cls=GroupIteration
18+
_from_parent_attrs= {"group_id":"id"}
19+
_list_filters= ("state","search","include_ancestors")
20+
21+
22+
classProjectIterationManager(ListMixin,RESTManager):
23+
_path="/projects/{project_id}/iterations"
24+
_obj_cls=GroupIteration
25+
_from_parent_attrs= {"project_id":"id"}
26+
_list_filters= ("state","search","include_ancestors")

‎gitlab/v4/objects/projects.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
from .integrationsimportProjectIntegrationManager,ProjectServiceManager# noqa: F401
5858
from .invitationsimportProjectInvitationManager# noqa: F401
5959
from .issuesimportProjectIssueManager# noqa: F401
60+
from .iterationsimportGroupIterationManager# noqa: F401
6061
from .jobsimportProjectJobManager# noqa: F401
6162
from .labelsimportProjectLabelManager# noqa: F401
6263
from .membersimportProjectMemberAllManager,ProjectMemberManager# noqa: F401
@@ -185,6 +186,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO
185186
invitations:ProjectInvitationManager
186187
issues:ProjectIssueManager
187188
issues_statistics:ProjectIssuesStatisticsManager
189+
iterations:GroupIterationManager
188190
jobs:ProjectJobManager
189191
keys:ProjectKeyManager
190192
labels:ProjectLabelManager

‎tests/unit/objects/test_iterations.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
"""
2+
GitLab API: https://docs.gitlab.com/ee/api/iterations.html
3+
"""
4+
5+
importre
6+
7+
importpytest
8+
importresponses
9+
10+
iterations_content= [
11+
{
12+
"id":53,
13+
"iid":13,
14+
"group_id":5,
15+
"title":"Iteration II",
16+
"description":"Ipsum Lorem ipsum",
17+
"state":2,
18+
"created_at":"2020-01-27T05:07:12.573Z",
19+
"updated_at":"2020-01-27T05:07:12.573Z",
20+
"due_date":"2020-02-01",
21+
"start_date":"2020-02-14",
22+
"web_url":"http://gitlab.example.com/groups/my-group/-/iterations/13",
23+
}
24+
]
25+
26+
27+
@pytest.fixture
28+
defresp_iterations_list():
29+
withresponses.RequestsMock()asrsps:
30+
rsps.add(
31+
method=responses.GET,
32+
url=re.compile(r"http://localhost/api/v4/(groups|projects)/1/iterations"),
33+
json=iterations_content,
34+
content_type="application/json",
35+
status=200,
36+
)
37+
yieldrsps
38+
39+
40+
deftest_list_group_iterations(group,resp_iterations_list):
41+
iterations=group.iterations.list()
42+
assertiterations[0].group_id==5
43+
44+
45+
deftest_list_project_iterations(project,resp_iterations_list):
46+
iterations=project.iterations.list()
47+
assertiterations[0].group_id==5

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp