forked from pyapi-gitlab/pyapi-gitlab
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_get.py
More file actions
33 lines (26 loc) · 993 Bytes
/
test_get.py
File metadata and controls
33 lines (26 loc) · 993 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from requests.exceptions import HTTPError
import responses
from gitlab_tests.base_test import BaseTest
from response_data.users import get_users
class TestGet(BaseTest):
@responses.activate
def test_get_with_200(self):
responses.add(
responses.GET,
self.gitlab.api_url + '/users',
json=get_users,
status=200,
content_type='application/json')
self.assertEqual(get_users, self.gitlab.get('/users'))
self.assertEqual(get_users, self.gitlab.get('/users', default_response={}))
@responses.activate
def test_get_with_404(self):
responses.add(
responses.GET,
self.gitlab.api_url + '/users',
body='{"error": "Not here"}',
status=404,
content_type='application/json')
self.gitlab.suppress_http_error = False
self.assertRaises(HTTPError, self.gitlab.get, '/users')
self.gitlab.suppress_http_error = True