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_post.py
More file actions
44 lines (38 loc) · 1.35 KB
/
test_post.py
File metadata and controls
44 lines (38 loc) · 1.35 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
import responses
from requests.exceptions import HTTPError
from gitlab_tests.base_test import BaseTest
from response_data.users import post_users, post_users_error
class TestPost(BaseTest):
@responses.activate
def test_post_with_201(self):
responses.add(
responses.POST,
self.gitlab.api_url + '/users',
json=post_users,
status=201,
content_type='application/json')
data = {
'name': 'test',
'username': 'test1',
'password': 'MyTestPassword1',
'email': 'example@example.com'
}
self.assertEqual(post_users, self.gitlab.post('/users', **data))
self.assertEqual(post_users, self.gitlab.post('/users', default_response={}, **data))
@responses.activate
def test_get_with_404(self):
responses.add(
responses.POST,
self.gitlab.api_url + '/users',
body=post_users_error,
status=409,
content_type='application/json')
data = {
'name': 'test',
'username': 'test1',
'password': 'MyTestPassword1',
'email': 'example@example.com'
}
self.gitlab.suppress_http_error = False
self.assertRaises(HTTPError, self.gitlab.post, '/users', **data)
self.gitlab.suppress_http_error = True