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

Commit10225cf

Browse files
committed
test(objects): add tests for resource state events
1 parent4d00c12 commit10225cf

File tree

2 files changed

+115
-0
lines changed

2 files changed

+115
-0
lines changed

‎gitlab/tests/conftest.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@ def project(gl):
5252
returngl.projects.get(1,lazy=True)
5353

5454

55+
@pytest.fixture
56+
defproject_issue(project):
57+
returnproject.issues.get(1,lazy=True)
58+
59+
60+
@pytest.fixture
61+
defproject_merge_request(project):
62+
returnproject.mergerequests.get(1,lazy=True)
63+
64+
5565
@pytest.fixture
5666
defrelease(project,tag_name):
5767
returnproject.releases.get(tag_name,lazy=True)
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
"""
2+
GitLab API: https://docs.gitlab.com/ee/api/resource_state_events.html
3+
"""
4+
5+
importpytest
6+
importresponses
7+
8+
fromgitlab.v4.objectsimport (
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+
defresp_list_project_issue_state_events():
20+
withresponses.RequestsMock()asrsps:
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+
yieldrsps
29+
30+
31+
@pytest.fixture()
32+
defresp_get_project_issue_state_event():
33+
withresponses.RequestsMock()asrsps:
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+
yieldrsps
42+
43+
44+
@pytest.fixture()
45+
defresp_list_merge_request_state_events():
46+
withresponses.RequestsMock()asrsps:
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+
yieldrsps
55+
56+
57+
@pytest.fixture()
58+
defresp_get_merge_request_state_event():
59+
withresponses.RequestsMock()asrsps:
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+
yieldrsps
68+
69+
70+
deftest_list_project_issue_state_events(
71+
project_issue,resp_list_project_issue_state_events
72+
):
73+
state_events=project_issue.resourcestateevents.list()
74+
assertisinstance(state_events,list)
75+
76+
state_event=state_events[0]
77+
assertisinstance(state_event,ProjectIssueResourceStateEvent)
78+
assertstate_event.resource_type=="Issue"
79+
80+
81+
deftest_get_project_issue_state_event(
82+
project_issue,resp_get_project_issue_state_event
83+
):
84+
state_event=project_issue.resourcestateevents.get(1)
85+
assertisinstance(state_event,ProjectIssueResourceStateEvent)
86+
assertstate_event.resource_type=="Issue"
87+
88+
89+
deftest_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+
assertisinstance(state_events,list)
94+
95+
state_event=state_events[0]
96+
assertisinstance(state_event,ProjectMergeRequestResourceStateEvent)
97+
assertstate_event.resource_type=="MergeRequest"
98+
99+
100+
deftest_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+
assertisinstance(state_event,ProjectMergeRequestResourceStateEvent)
105+
assertstate_event.resource_type=="MergeRequest"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp