X Tutup
Skip to content

Commit 1db3cc1

Browse files
author
Gauvain Pocentek
committed
fix the tests
1 parent 2a76b74 commit 1db3cc1

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

gitlab/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,9 @@ def list(cls, gl, **kwargs):
697697

698698
@classmethod
699699
def get(cls, gl, id, **kwargs):
700-
if cls.canGet is True:
700+
if cls.canGet is False:
701+
raise NotImplementedError
702+
elif cls.canGet is True:
701703
return cls(gl, id, **kwargs)
702704
elif cls.canGet == 'from_list':
703705
for obj in cls.list(gl, **kwargs):

gitlab/tests/test_gitlab.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -677,15 +677,19 @@ def resp_get_group(url, request):
677677
self.assertEqual(data.id, 1)
678678

679679
def test_Issue(self):
680-
@urlmatch(scheme="http", netloc="localhost", path="/api/v3/issues/1",
680+
@urlmatch(scheme="http", netloc="localhost", path="/api/v3/issues",
681681
method="get")
682682
def resp_get_issue(url, request):
683683
headers = {'content-type': 'application/json'}
684-
content = '{"name": "name", "id": 1}'.encode("utf-8")
684+
content = ('[{"name": "name", "id": 1}, '
685+
'{"name": "other_name", "id": 2}]')
686+
content = content.encode("utf-8")
685687
return response(200, content, headers, None, 5, request)
686688

687689
with HTTMock(resp_get_issue):
688-
self.assertRaises(NotImplementedError, self.gl.Issue, id=1)
690+
data = self.gl.Issue(id=2)
691+
self.assertEqual(data.id, 2)
692+
self.assertEqual(data.name, 'other_name')
689693

690694
def test_User(self):
691695
@urlmatch(scheme="http", netloc="localhost", path="/api/v3/users/1",

0 commit comments

Comments
 (0)
X Tutup