diff options
-rw-r--r-- | gitlab/__init__.py | 4 | ||||
-rw-r--r-- | gitlab/tests/test_gitlab.py | 10 |
2 files changed, 10 insertions, 4 deletions
diff --git a/gitlab/__init__.py b/gitlab/__init__.py index 7b23903..ebd7648 100644 --- a/gitlab/__init__.py +++ b/gitlab/__init__.py @@ -697,7 +697,9 @@ class GitlabObject(object): @classmethod def get(cls, gl, id, **kwargs): - if cls.canGet is True: + if cls.canGet is False: + raise NotImplementedError + elif cls.canGet is True: return cls(gl, id, **kwargs) elif cls.canGet == 'from_list': for obj in cls.list(gl, **kwargs): diff --git a/gitlab/tests/test_gitlab.py b/gitlab/tests/test_gitlab.py index a0f35bb..8331964 100644 --- a/gitlab/tests/test_gitlab.py +++ b/gitlab/tests/test_gitlab.py @@ -677,15 +677,19 @@ class TestGitLab(unittest.TestCase): self.assertEqual(data.id, 1) def test_Issue(self): - @urlmatch(scheme="http", netloc="localhost", path="/api/v3/issues/1", + @urlmatch(scheme="http", netloc="localhost", path="/api/v3/issues", method="get") def resp_get_issue(url, request): headers = {'content-type': 'application/json'} - content = '{"name": "name", "id": 1}'.encode("utf-8") + content = ('[{"name": "name", "id": 1}, ' + '{"name": "other_name", "id": 2}]') + content = content.encode("utf-8") return response(200, content, headers, None, 5, request) with HTTMock(resp_get_issue): - self.assertRaises(NotImplementedError, self.gl.Issue, id=1) + data = self.gl.Issue(id=2) + self.assertEqual(data.id, 2) + self.assertEqual(data.name, 'other_name') def test_User(self): @urlmatch(scheme="http", netloc="localhost", path="/api/v3/users/1", |