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

Commitc7cf0d1

Browse files
committed
test(unit): expand tests for pipeline schedules
1 parent9a9a6a9 commitc7cf0d1

File tree

2 files changed

+54
-4
lines changed

2 files changed

+54
-4
lines changed

‎tests/unit/conftest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ def release(project, tag_name):
8989
returnproject.releases.get(tag_name,lazy=True)
9090

9191

92+
@pytest.fixture
93+
defschedule(project):
94+
returnproject.pipelineschedules.get(1,lazy=True)
95+
96+
9297
@pytest.fixture
9398
defuser(gl):
9499
returngl.users.get(1,lazy=True)

‎tests/unit/objects/test_pipeline_schedules.py

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,24 @@
44
importpytest
55
importresponses
66

7+
fromgitlab.v4.objectsimportProjectPipelineSchedulePipeline
8+
9+
pipeline_content= {
10+
"id":48,
11+
"iid":13,
12+
"project_id":29,
13+
"status":"pending",
14+
"source":"scheduled",
15+
"ref":"new-pipeline",
16+
"sha":"eb94b618fb5865b26e80fdd8ae531b7a63ad851a",
17+
"web_url":"https://example.com/foo/bar/pipelines/48",
18+
"created_at":"2016-08-12T10:06:04.561Z",
19+
"updated_at":"2016-08-12T10:09:56.223Z",
20+
}
21+
722

823
@pytest.fixture
9-
defresp_project_pipeline_schedule(created_content):
24+
defresp_create_pipeline_schedule():
1025
content= {
1126
"id":14,
1227
"description":"Build packages",
@@ -36,17 +51,36 @@ def resp_project_pipeline_schedule(created_content):
3651
content_type="application/json",
3752
status=200,
3853
)
54+
yieldrsps
55+
56+
57+
@pytest.fixture
58+
defresp_play_pipeline_schedule(created_content):
59+
withresponses.RequestsMock()asrsps:
3960
rsps.add(
4061
method=responses.POST,
41-
url="http://localhost/api/v4/projects/1/pipeline_schedules/14/play",
62+
url="http://localhost/api/v4/projects/1/pipeline_schedules/1/play",
4263
json=created_content,
4364
content_type="application/json",
4465
status=201,
4566
)
4667
yieldrsps
4768

4869

49-
deftest_project_pipeline_schedule_play(project,resp_project_pipeline_schedule):
70+
@pytest.fixture
71+
defresp_list_schedule_pipelines():
72+
withresponses.RequestsMock()asrsps:
73+
rsps.add(
74+
method=responses.GET,
75+
url="http://localhost/api/v4/projects/1/pipeline_schedules/1/pipelines",
76+
json=[pipeline_content],
77+
content_type="application/json",
78+
status=200,
79+
)
80+
yieldrsps
81+
82+
83+
deftest_create_project_pipeline_schedule(project,resp_create_pipeline_schedule):
5084
description="Build packages"
5185
cronline="0 1 * * 5"
5286
sched=project.pipelineschedules.create(
@@ -56,7 +90,18 @@ def test_project_pipeline_schedule_play(project, resp_project_pipeline_schedule)
5690
assertdescription==sched.description
5791
assertcronline==sched.cron
5892

59-
play_result=sched.play()
93+
94+
deftest_play_project_pipeline_schedule(schedule,resp_play_pipeline_schedule):
95+
play_result=schedule.play()
6096
assertplay_resultisnotNone
6197
assert"message"inplay_result
6298
assertplay_result["message"]=="201 Created"
99+
100+
101+
deftest_list_project_pipeline_schedule_pipelines(
102+
schedule,resp_list_schedule_pipelines
103+
):
104+
pipelines=schedule.pipelines.list()
105+
assertisinstance(pipelines,list)
106+
assertisinstance(pipelines[0],ProjectPipelineSchedulePipeline)
107+
assertpipelines[0].source=="scheduled"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp