summaryrefslogtreecommitdiff
path: root/gitlab/tests
diff options
context:
space:
mode:
authorMax Wittig <max.wittig@siemens.com>2019-10-24 08:50:39 +0200
committerMax Wittig <max.wittig@siemens.com>2019-10-24 09:17:07 +0200
commitca256a07a2cdaf77a5c20e307d334b82fd0fe861 (patch)
treed17e58ebcd62a2e92905b79f358cc94ad4f5b968 /gitlab/tests
parente790b1ec40ed690152776a87c15e7f7d5d3b9136 (diff)
downloadgitlab-feat/deployment-create.tar.gz
feat: add deployment creationfeat/deployment-create
Added in GitLab 12.4 Fixes #917
Diffstat (limited to 'gitlab/tests')
-rw-r--r--gitlab/tests/test_gitlab.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/gitlab/tests/test_gitlab.py b/gitlab/tests/test_gitlab.py
index 665810c..c208b31 100644
--- a/gitlab/tests/test_gitlab.py
+++ b/gitlab/tests/test_gitlab.py
@@ -651,6 +651,50 @@ class TestGitlab(unittest.TestCase):
with HTTMock(resp_mark_all_as_done):
self.gl.todos.mark_all_as_done()
+ def test_deployment(self):
+ content = '{"id": 42, "status": "success", "ref": "master"}'
+ json_content = json.loads(content)
+
+ @urlmatch(
+ scheme="http",
+ netloc="localhost",
+ path="/api/v4/projects/1/deployments",
+ method="post",
+ )
+ def resp_deployment_create(url, request):
+ headers = {"content-type": "application/json"}
+ return response(200, json_content, headers, None, 5, request)
+
+ @urlmatch(
+ scheme="http",
+ netloc="localhost",
+ path="/api/v4/projects/1/deployments/42",
+ method="put",
+ )
+ def resp_deployment_update(url, request):
+ headers = {"content-type": "application/json"}
+ return response(200, json_content, headers, None, 5, request)
+
+ with HTTMock(resp_deployment_create):
+ deployment = self.gl.projects.get(1, lazy=True).deployments.create(
+ {
+ "environment": "Test",
+ "sha": "1agf4gs",
+ "ref": "master",
+ "tag": False,
+ "status": "created",
+ }
+ )
+ self.assertEqual(deployment.id, 42)
+ self.assertEqual(deployment.status, "success")
+ self.assertEqual(deployment.ref, "master")
+
+ with HTTMock(resp_deployment_update):
+ json_content["status"] = "failed"
+ deployment.status = "failed"
+ deployment.save()
+ self.assertEqual(deployment.status, "failed")
+
def test_update_submodule(self):
@urlmatch(
scheme="http", netloc="localhost", path="/api/v4/projects/1$", method="get"