This repository was archived by the owner on Nov 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 104
Expand file tree
/
Copy pathtest_users.py
More file actions
64 lines (53 loc) · 2.02 KB
/
test_users.py
File metadata and controls
64 lines (53 loc) · 2.02 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import responses
from requests.exceptions import HTTPError
from gitlab_tests.base_test import BaseTest
from response_data.users import *
class TestGetUsers(BaseTest):
@responses.activate
def test_get_users(self):
responses.add(
responses.GET,
self.gitlab.api_url + '/users',
match_querystring=False,
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(search='test'))
self.assertEqual(get_users, self.gitlab.getusers())
@responses.activate
def test_get_users_exception(self):
responses.add(
responses.GET,
self.gitlab.api_url + '/users',
match_querystring=False,
json='{"error": "Not found"}',
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
self.assertEqual(False, self.gitlab.getusers())
class TestDeleteUser(BaseTest):
@responses.activate
def test_delete_user(self):
responses.add(
responses.DELETE,
self.gitlab.api_url + '/users/14',
json=delete_user,
status=204,
content_type='application/json')
self.assertEqual(delete_user, self.gitlab.delete_user(14))
self.assertTrue(self.gitlab.deleteuser(14))
@responses.activate
def test_get_users_exception(self):
responses.add(
responses.DELETE,
self.gitlab.api_url + '/users/14',
body='{"error": "Not found"}',
status=404,
content_type='application/json')
self.gitlab.suppress_http_error = False
self.assertRaises(HTTPError, self.gitlab.delete_user, 14)
self.gitlab.suppress_http_error = True
self.assertFalse(self.gitlab.deleteuser(14))