summaryrefslogtreecommitdiff
path: root/gitlab/tests/test_gitlab.py
diff options
context:
space:
mode:
authorGauvain Pocentek <gauvain.pocentek@objectif-libre.com>2016-01-10 18:21:46 +0100
committerGauvain Pocentek <gauvain.pocentek@objectif-libre.com>2016-01-10 18:21:46 +0100
commit1d7ebea727c2fa68135ef4290dfe51604d843688 (patch)
treebad1985ed2fd1d4196628e862643eb0870d18dc6 /gitlab/tests/test_gitlab.py
parente5821e6a39344d545ac230ac6d868a8f0aaeb46b (diff)
downloadgitlab-1d7ebea727c2fa68135ef4290dfe51604d843688.tar.gz
Support deletion without getting the object first
Use this feature in the CLI to avoid an extra API call to the server.
Diffstat (limited to 'gitlab/tests/test_gitlab.py')
-rw-r--r--gitlab/tests/test_gitlab.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/gitlab/tests/test_gitlab.py b/gitlab/tests/test_gitlab.py
index 337320f..7872083 100644
--- a/gitlab/tests/test_gitlab.py
+++ b/gitlab/tests/test_gitlab.py
@@ -338,7 +338,7 @@ class TestGitlabMethods(unittest.TestCase):
self.assertRaises(GitlabGetError, self.gl.get,
Project, 1)
- def test_delete(self):
+ def test_delete_from_object(self):
@urlmatch(scheme="http", netloc="localhost", path="/api/v3/groups/1",
method="delete")
def resp_delete_group(url, request):
@@ -351,6 +351,24 @@ class TestGitlabMethods(unittest.TestCase):
data = self.gl.delete(obj)
self.assertIs(data, True)
+ def test_delete_from_invalid_class(self):
+ class InvalidClass(object):
+ pass
+
+ self.assertRaises(GitlabError, self.gl.delete, InvalidClass, 1)
+
+ def test_delete_from_class(self):
+ @urlmatch(scheme="http", netloc="localhost", path="/api/v3/groups/1",
+ method="delete")
+ def resp_delete_group(url, request):
+ headers = {'content-type': 'application/json'}
+ content = ''.encode("utf-8")
+ return response(200, content, headers, None, 5, request)
+
+ with HTTMock(resp_delete_group):
+ data = self.gl.delete(Group, 1)
+ self.assertIs(data, True)
+
def test_delete_unknown_path(self):
obj = Project(self.gl, data={"name": "testname", "id": 1})
obj._from_api = True