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 path__init__.py
More file actions
51 lines (42 loc) · 1.26 KB
/
__init__.py
File metadata and controls
51 lines (42 loc) · 1.26 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
import responses
from requests.exceptions import HTTPError
from gitlab_tests.base_test import BaseTest
from response_data import not_found
from response_data.keys import get_keys
class TestKeys(BaseTest):
@responses.activate
def test_keys(self):
responses.add(
responses.GET,
self.gitlab.api_url + '/keys/1',
json=get_keys,
status=201,
content_type='application/json'
)
self.assertEqual(
self.gitlab.keys(1),
get_keys
)
self.assertEqual(
self.gitlab.getsshkey(1),
get_keys
)
@responses.activate
def test_keys_with_bad_data(self):
responses.add(
responses.GET,
self.gitlab.api_url + '/keys/1',
json=not_found,
status=404,
content_type='application/json'
)
self.assertRaises(
HTTPError,
self.gitlab.keys, 1
)
# Don't raise exception when suppress http error is True
self.gitlab.suppress_http_error = True
self.assertFalse(self.gitlab.keys(1))
# Deprecated version test
self.assertFalse(self.gitlab.getsshkey(1))
self.gitlab.suppress_http_error = False