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

Commit9fed061

Browse files
committed
fix(objects): return server data in cancel/retry methods
1 parentb563cdc commit9fed061

File tree

4 files changed

+196
-4
lines changed

4 files changed

+196
-4
lines changed

‎gitlab/tests/objects/test_jobs.py

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
"""
2+
GitLab API: https://docs.gitlab.com/ee/api/jobs.html
3+
"""
4+
importpytest
5+
importresponses
6+
7+
fromgitlab.v4.objectsimportProjectJob
8+
9+
10+
job_content= {
11+
"commit": {
12+
"author_email":"admin@example.com",
13+
"author_name":"Administrator",
14+
},
15+
"coverage":None,
16+
"allow_failure":False,
17+
"created_at":"2015-12-24T15:51:21.880Z",
18+
"started_at":"2015-12-24T17:54:30.733Z",
19+
"finished_at":"2015-12-24T17:54:31.198Z",
20+
"duration":0.465,
21+
"queued_duration":0.010,
22+
"artifacts_expire_at":"2016-01-23T17:54:31.198Z",
23+
"tag_list": ["docker runner","macos-10.15"],
24+
"id":1,
25+
"name":"rubocop",
26+
"pipeline": {
27+
"id":1,
28+
"project_id":1,
29+
},
30+
"ref":"master",
31+
"artifacts": [],
32+
"runner":None,
33+
"stage":"test",
34+
"status":"failed",
35+
"tag":False,
36+
"web_url":"https://example.com/foo/bar/-/jobs/1",
37+
"user": {"id":1},
38+
}
39+
40+
41+
@pytest.fixture
42+
defresp_get_job():
43+
withresponses.RequestsMock()asrsps:
44+
rsps.add(
45+
method=responses.GET,
46+
url="http://localhost/api/v4/projects/1/jobs/1",
47+
json=job_content,
48+
content_type="application/json",
49+
status=200,
50+
)
51+
yieldrsps
52+
53+
54+
@pytest.fixture
55+
defresp_cancel_job():
56+
withresponses.RequestsMock()asrsps:
57+
rsps.add(
58+
method=responses.POST,
59+
url="http://localhost/api/v4/projects/1/jobs/1/cancel",
60+
json=job_content,
61+
content_type="application/json",
62+
status=201,
63+
)
64+
yieldrsps
65+
66+
67+
@pytest.fixture
68+
defresp_retry_job():
69+
withresponses.RequestsMock()asrsps:
70+
rsps.add(
71+
method=responses.POST,
72+
url="http://localhost/api/v4/projects/1/jobs/1/retry",
73+
json=job_content,
74+
content_type="application/json",
75+
status=201,
76+
)
77+
yieldrsps
78+
79+
80+
deftest_get_project_job(project,resp_get_job):
81+
job=project.jobs.get(1)
82+
assertisinstance(job,ProjectJob)
83+
assertjob.ref=="master"
84+
85+
86+
deftest_cancel_project_job(project,resp_cancel_job):
87+
job=project.jobs.get(1,lazy=True)
88+
89+
output=job.cancel()
90+
assertoutput["ref"]=="master"
91+
92+
93+
deftest_retry_project_job(project,resp_retry_job):
94+
job=project.jobs.get(1,lazy=True)
95+
96+
output=job.retry()
97+
assertoutput["ref"]=="master"
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
"""
2+
GitLab API: https://docs.gitlab.com/ee/api/pipelines.html
3+
"""
4+
importpytest
5+
importresponses
6+
7+
fromgitlab.v4.objectsimportProjectPipeline
8+
9+
10+
pipeline_content= {
11+
"id":46,
12+
"project_id":1,
13+
"status":"pending",
14+
"ref":"master",
15+
"sha":"a91957a858320c0e17f3a0eca7cfacbff50ea29a",
16+
"before_sha":"a91957a858320c0e17f3a0eca7cfacbff50ea29a",
17+
"tag":False,
18+
"yaml_errors":None,
19+
"user": {
20+
"name":"Administrator",
21+
"username":"root",
22+
"id":1,
23+
"state":"active",
24+
"avatar_url":"http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
25+
"web_url":"http://localhost:3000/root",
26+
},
27+
"created_at":"2016-08-11T11:28:34.085Z",
28+
"updated_at":"2016-08-11T11:32:35.169Z",
29+
"started_at":None,
30+
"finished_at":"2016-08-11T11:32:35.145Z",
31+
"committed_at":None,
32+
"duration":None,
33+
"queued_duration":0.010,
34+
"coverage":None,
35+
"web_url":"https://example.com/foo/bar/pipelines/46",
36+
}
37+
38+
39+
@pytest.fixture
40+
defresp_get_pipeline():
41+
withresponses.RequestsMock()asrsps:
42+
rsps.add(
43+
method=responses.GET,
44+
url="http://localhost/api/v4/projects/1/pipelines/1",
45+
json=pipeline_content,
46+
content_type="application/json",
47+
status=200,
48+
)
49+
yieldrsps
50+
51+
52+
@pytest.fixture
53+
defresp_cancel_pipeline():
54+
withresponses.RequestsMock()asrsps:
55+
rsps.add(
56+
method=responses.POST,
57+
url="http://localhost/api/v4/projects/1/pipelines/1/cancel",
58+
json=pipeline_content,
59+
content_type="application/json",
60+
status=201,
61+
)
62+
yieldrsps
63+
64+
65+
@pytest.fixture
66+
defresp_retry_pipeline():
67+
withresponses.RequestsMock()asrsps:
68+
rsps.add(
69+
method=responses.POST,
70+
url="http://localhost/api/v4/projects/1/pipelines/1/retry",
71+
json=pipeline_content,
72+
content_type="application/json",
73+
status=201,
74+
)
75+
yieldrsps
76+
77+
78+
deftest_get_project_pipeline(project,resp_get_pipeline):
79+
pipeline=project.pipelines.get(1)
80+
assertisinstance(pipeline,ProjectPipeline)
81+
assertpipeline.ref=="master"
82+
83+
84+
deftest_cancel_project_pipeline(project,resp_cancel_pipeline):
85+
pipeline=project.pipelines.get(1,lazy=True)
86+
87+
output=pipeline.cancel()
88+
assertoutput["ref"]=="master"
89+
90+
91+
deftest_retry_project_pipeline(project,resp_retry_pipeline):
92+
pipeline=project.pipelines.get(1,lazy=True)
93+
94+
output=pipeline.retry()
95+
assertoutput["ref"]=="master"

‎gitlab/v4/objects/jobs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def cancel(self, **kwargs):
2424
GitlabJobCancelError: If the job could not be canceled
2525
"""
2626
path="%s/%s/cancel"% (self.manager.path,self.get_id())
27-
self.manager.gitlab.http_post(path)
27+
returnself.manager.gitlab.http_post(path)
2828

2929
@cli.register_custom_action("ProjectJob")
3030
@exc.on_http_error(exc.GitlabJobRetryError)
@@ -39,7 +39,7 @@ def retry(self, **kwargs):
3939
GitlabJobRetryError: If the job could not be retried
4040
"""
4141
path="%s/%s/retry"% (self.manager.path,self.get_id())
42-
self.manager.gitlab.http_post(path)
42+
returnself.manager.gitlab.http_post(path)
4343

4444
@cli.register_custom_action("ProjectJob")
4545
@exc.on_http_error(exc.GitlabJobPlayError)

‎gitlab/v4/objects/pipelines.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def cancel(self, **kwargs):
5050
GitlabPipelineCancelError: If the request failed
5151
"""
5252
path="%s/%s/cancel"% (self.manager.path,self.get_id())
53-
self.manager.gitlab.http_post(path)
53+
returnself.manager.gitlab.http_post(path)
5454

5555
@cli.register_custom_action("ProjectPipeline")
5656
@exc.on_http_error(exc.GitlabPipelineRetryError)
@@ -65,7 +65,7 @@ def retry(self, **kwargs):
6565
GitlabPipelineRetryError: If the request failed
6666
"""
6767
path="%s/%s/retry"% (self.manager.path,self.get_id())
68-
self.manager.gitlab.http_post(path)
68+
returnself.manager.gitlab.http_post(path)
6969

7070

7171
classProjectPipelineManager(RetrieveMixin,CreateMixin,DeleteMixin,RESTManager):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp