@@ -257,6 +257,45 @@ def resp_get_active_services(url, request):
257257 return response (200 , content , headers , None , 5 , request )
258258
259259
260+ @urlmatch (
261+ scheme = "http" , netloc = "localhost" , path = "/api/v4/projects/1/pipeline_schedules$" , method = "post" ,
262+ )
263+ def resp_create_project_pipeline_schedule (url , request ):
264+ """Mock for creating project pipeline Schedules POST response."""
265+ content = """{
266+ "id": 14,
267+ "description": "Build packages",
268+ "ref": "master",
269+ "cron": "0 1 * * 5",
270+ "cron_timezone": "UTC",
271+ "next_run_at": "2017-05-26T01:00:00.000Z",
272+ "active": true,
273+ "created_at": "2017-05-19T13:43:08.169Z",
274+ "updated_at": "2017-05-19T13:43:08.169Z",
275+ "last_pipeline": null,
276+ "owner": {
277+ "name": "Administrator",
278+ "username": "root",
279+ "id": 1,
280+ "state": "active",
281+ "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
282+ "web_url": "https://gitlab.example.com/root"
283+ }
284+ }"""
285+ content = content .encode ("utf-8" )
286+ return response (200 , content , headers , None , 5 , request )
287+
288+
289+ @urlmatch (
290+ scheme = "http" , netloc = "localhost" , path = "/api/v4/projects/1/pipeline_schedules/14/play" , method = "post" ,
291+ )
292+ def resp_play_project_pipeline_schedule (url , request ):
293+ """Mock for playing a project pipeline schedule POST response."""
294+ content = """{"message": "201 Created"}"""
295+ content = content .encode ("utf-8" )
296+ return response (200 , content , headers , None , 5 , request )
297+
298+
260299class TestProject (unittest .TestCase ):
261300 """Base class for GitLab Project tests."""
262301
@@ -484,15 +523,21 @@ def test_update_service(self):
484523
485524class TestProjectPipelineSchedule (TestProject ):
486525
526+ @with_httmock (resp_create_project_pipeline_schedule ,
527+ resp_play_project_pipeline_schedule )
487528 def test_project_pipeline_schedule_play (self ):
529+ description = 'Build packages'
530+ cronline = '0 1 * * 5'
488531 sched = self .project .pipelineschedules .create ({
489532 'ref' : 'master' ,
490- 'description' : 'Daily test' ,
491- 'cron' : '0 1 * * *' })
492- print (sched )
533+ 'description' : description ,
534+ 'cron' : cronline })
493535 self .assertIsNotNone (sched )
536+ self .assertEqual (description , sched .description )
537+ self .assertEqual (cronline , sched .cron )
538+
494539 play_result = sched .play ()
495- print (play_result )
496540 self .assertIsNotNone (play_result )
497- self .fail ('not complete' )
541+ self .assertIn ('message' , play_result )
542+ self .assertEqual ('201 Created' , play_result ['message' ])
498543
0 commit comments