summaryrefslogtreecommitdiff
path: root/gitlab/tests/objects/test_projects.py
diff options
context:
space:
mode:
Diffstat (limited to 'gitlab/tests/objects/test_projects.py')
-rw-r--r--gitlab/tests/objects/test_projects.py65
1 files changed, 65 insertions, 0 deletions
diff --git a/gitlab/tests/objects/test_projects.py b/gitlab/tests/objects/test_projects.py
index 6a2840a..ca7e0c8 100644
--- a/gitlab/tests/objects/test_projects.py
+++ b/gitlab/tests/objects/test_projects.py
@@ -257,6 +257,51 @@ def resp_get_active_services(url, request):
return response(200, content, headers, None, 5, request)
+@urlmatch(
+ scheme="http",
+ netloc="localhost",
+ path="/api/v4/projects/1/pipeline_schedules$",
+ method="post",
+)
+def resp_create_project_pipeline_schedule(url, request):
+ """Mock for creating project pipeline Schedules POST response."""
+ content = """{
+ "id": 14,
+ "description": "Build packages",
+ "ref": "master",
+ "cron": "0 1 * * 5",
+ "cron_timezone": "UTC",
+ "next_run_at": "2017-05-26T01:00:00.000Z",
+ "active": true,
+ "created_at": "2017-05-19T13:43:08.169Z",
+ "updated_at": "2017-05-19T13:43:08.169Z",
+ "last_pipeline": null,
+ "owner": {
+ "name": "Administrator",
+ "username": "root",
+ "id": 1,
+ "state": "active",
+ "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
+ "web_url": "https://gitlab.example.com/root"
+ }
+}"""
+ content = content.encode("utf-8")
+ return response(200, content, headers, None, 5, request)
+
+
+@urlmatch(
+ scheme="http",
+ netloc="localhost",
+ path="/api/v4/projects/1/pipeline_schedules/14/play",
+ method="post",
+)
+def resp_play_project_pipeline_schedule(url, request):
+ """Mock for playing a project pipeline schedule POST response."""
+ content = """{"message": "201 Created"}"""
+ content = content.encode("utf-8")
+ return response(200, content, headers, None, 5, request)
+
+
class TestProject(unittest.TestCase):
"""Base class for GitLab Project tests."""
@@ -480,3 +525,23 @@ class TestProjectServices(TestProject):
service.issues_events = True
service.save()
self.assertEqual(service.issues_events, True)
+
+
+class TestProjectPipelineSchedule(TestProject):
+ @with_httmock(
+ resp_create_project_pipeline_schedule, resp_play_project_pipeline_schedule
+ )
+ def test_project_pipeline_schedule_play(self):
+ description = "Build packages"
+ cronline = "0 1 * * 5"
+ sched = self.project.pipelineschedules.create(
+ {"ref": "master", "description": description, "cron": cronline}
+ )
+ self.assertIsNotNone(sched)
+ self.assertEqual(description, sched.description)
+ self.assertEqual(cronline, sched.cron)
+
+ play_result = sched.play()
+ self.assertIsNotNone(play_result)
+ self.assertIn("message", play_result)
+ self.assertEqual("201 Created", play_result["message"])