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

Appearance settings

Commit c7cf0d1

Browse filesBrowse files
committed
test(unit): expand tests for pipeline schedules
1 parent 9a9a6a9 commit c7cf0d1
Copy full SHA for c7cf0d1

File tree

Expand file treeCollapse file tree

2 files changed

+54
-4
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+54
-4
lines changed
Open diff view settings
Collapse file

‎tests/unit/conftest.py‎

Copy file name to clipboardExpand all lines: tests/unit/conftest.py
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ def release(project, tag_name):
8989
return project.releases.get(tag_name, lazy=True)
9090

9191

92+
@pytest.fixture
93+
def schedule(project):
94+
return project.pipelineschedules.get(1, lazy=True)
95+
96+
9297
@pytest.fixture
9398
def user(gl):
9499
return gl.users.get(1, lazy=True)
Collapse file

‎tests/unit/objects/test_pipeline_schedules.py‎

Copy file name to clipboardExpand all lines: tests/unit/objects/test_pipeline_schedules.py
+49-4Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,24 @@
44
import pytest
55
import responses
66

7+
from gitlab.v4.objects import ProjectPipelineSchedulePipeline
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-
def resp_project_pipeline_schedule(created_content):
24+
def resp_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+
yield rsps
55+
56+
57+
@pytest.fixture
58+
def resp_play_pipeline_schedule(created_content):
59+
with responses.RequestsMock() as rsps:
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
yield rsps
4768

4869

49-
def test_project_pipeline_schedule_play(project, resp_project_pipeline_schedule):
70+
@pytest.fixture
71+
def resp_list_schedule_pipelines():
72+
with responses.RequestsMock() as rsps:
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+
yield rsps
81+
82+
83+
def test_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
assert description == sched.description
5791
assert cronline == sched.cron
5892

59-
play_result = sched.play()
93+
94+
def test_play_project_pipeline_schedule(schedule, resp_play_pipeline_schedule):
95+
play_result = schedule.play()
6096
assert play_result is not None
6197
assert "message" in play_result
6298
assert play_result["message"] == "201 Created"
99+
100+
101+
def test_list_project_pipeline_schedule_pipelines(
102+
schedule, resp_list_schedule_pipelines
103+
):
104+
pipelines = schedule.pipelines.list()
105+
assert isinstance(pipelines, list)
106+
assert isinstance(pipelines[0], ProjectPipelineSchedulePipeline)
107+
assert pipelines[0].source == "scheduled"

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.