summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNejc Habjan <hab.nejc@gmail.com>2021-02-24 00:18:49 +0100
committerNejc Habjan <hab.nejc@gmail.com>2021-06-13 21:18:44 +0200
commit954357c49963ef51945c81c41fd4345002f9fb98 (patch)
tree13cd0da13d9a747cae56eff45fe27244f3c13a51 /tests
parente3aa0238da48589d41c84e3102611eb21d032ea5 (diff)
downloadgitlab-954357c49963ef51945c81c41fd4345002f9fb98.tar.gz
feat(api): add MR pipeline manager in favor of pipelines() method
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/objects/test_merge_request_pipelines.py64
1 files changed, 64 insertions, 0 deletions
diff --git a/tests/unit/objects/test_merge_request_pipelines.py b/tests/unit/objects/test_merge_request_pipelines.py
new file mode 100644
index 0000000..c620cb0
--- /dev/null
+++ b/tests/unit/objects/test_merge_request_pipelines.py
@@ -0,0 +1,64 @@
+"""
+GitLab API: https://docs.gitlab.com/ee/api/merge_requests.html#list-mr-pipelines
+"""
+import pytest
+import responses
+
+from gitlab.v4.objects import ProjectMergeRequestPipeline
+
+pipeline_content = {
+ "id": 1,
+ "sha": "959e04d7c7a30600c894bd3c0cd0e1ce7f42c11d",
+ "ref": "master",
+ "status": "success",
+}
+
+
+@pytest.fixture()
+def resp_list_merge_request_pipelines():
+ with responses.RequestsMock() as rsps:
+ rsps.add(
+ method=responses.GET,
+ url="http://localhost/api/v4/projects/1/merge_requests/1/pipelines",
+ json=[pipeline_content],
+ content_type="application/json",
+ status=200,
+ )
+ yield rsps
+
+
+@pytest.fixture()
+def resp_create_merge_request_pipeline():
+ with responses.RequestsMock() as rsps:
+ rsps.add(
+ method=responses.POST,
+ url="http://localhost/api/v4/projects/1/merge_requests/1/pipelines",
+ json=pipeline_content,
+ content_type="application/json",
+ status=201,
+ )
+ yield rsps
+
+
+def test_merge_requests_pipelines_deprecated_raises_warning(
+ project, resp_list_merge_request_pipelines
+):
+ with pytest.deprecated_call():
+ pipelines = project.mergerequests.get(1, lazy=True).pipelines()
+
+ assert len(pipelines) == 1
+ assert isinstance(pipelines[0], ProjectMergeRequestPipeline)
+ assert pipelines[0].sha == pipeline_content["sha"]
+
+
+def test_list_merge_requests_pipelines(project, resp_list_merge_request_pipelines):
+ pipelines = project.mergerequests.get(1, lazy=True).pipelines.list()
+ assert len(pipelines) == 1
+ assert isinstance(pipelines[0], ProjectMergeRequestPipeline)
+ assert pipelines[0].sha == pipeline_content["sha"]
+
+
+def test_create_merge_requests_pipelines(project, resp_create_merge_request_pipeline):
+ pipeline = project.mergerequests.get(1, lazy=True).pipelines.create()
+ assert isinstance(pipeline, ProjectMergeRequestPipeline)
+ assert pipeline.sha == pipeline_content["sha"]