| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -89,6 +89,11 @@ def release(project, tag_name): | |||
| 89 | 89 | return project.releases.get(tag_name, lazy=True) | |
| 90 | 90 | ||
| 91 | 91 | ||
| 92 | + @pytest.fixture | ||
| 93 | + def schedule(project): | ||
| 94 | + return project.pipelineschedules.get(1, lazy=True) | ||
| 95 | + | ||
| 96 | + | ||
| 92 | 97 | @pytest.fixture | |
| 93 | 98 | def user(gl): | |
| 94 | 99 | return gl.users.get(1, lazy=True) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,9 +4,24 @@ | |||
| 4 | 4 | import pytest | |
| 5 | 5 | import responses | |
| 6 | 6 | ||
| 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 | + | ||
| 7 | 22 | ||
| 8 | 23 | @pytest.fixture | |
| 9 | - def resp_project_pipeline_schedule(created_content): | ||
| 24 | + def resp_create_pipeline_schedule(): | ||
| 10 | 25 | content = { | |
| 11 | 26 | "id": 14, | |
| 12 | 27 | "description": "Build packages", | |
@@ -36,17 +51,36 @@ def resp_project_pipeline_schedule(created_content): | |||
| 36 | 51 | content_type="application/json", | |
| 37 | 52 | status=200, | |
| 38 | 53 | ) | |
| 54 | + yield rsps | ||
| 55 | + | ||
| 56 | + | ||
| 57 | + @pytest.fixture | ||
| 58 | + def resp_play_pipeline_schedule(created_content): | ||
| 59 | + with responses.RequestsMock() as rsps: | ||
| 39 | 60 | rsps.add( | |
| 40 | 61 | 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", | ||
| 42 | 63 | json=created_content, | |
| 43 | 64 | content_type="application/json", | |
| 44 | 65 | status=201, | |
| 45 | 66 | ) | |
| 46 | 67 | yield rsps | |
| 47 | 68 | ||
| 48 | 69 | ||
| 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): | ||
| 50 | 84 | description = "Build packages" | |
| 51 | 85 | cronline = "0 1 * * 5" | |
| 52 | 86 | sched = project.pipelineschedules.create( | |
@@ -56,7 +90,18 @@ def test_project_pipeline_schedule_play(project, resp_project_pipeline_schedule) | |||
| 56 | 90 | assert description == sched.description | |
| 57 | 91 | assert cronline == sched.cron | |
| 58 | 92 | ||
| 59 | - play_result = sched.play() | ||
| 93 | + | ||
| 94 | + def test_play_project_pipeline_schedule(schedule, resp_play_pipeline_schedule): | ||
| 95 | + play_result = schedule.play() | ||
| 60 | 96 | assert play_result is not None | |
| 61 | 97 | assert "message" in play_result | |
| 62 | 98 | 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" | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments