File tree 5 files changed +33
-22
lines changed
5 files changed +33
-22
lines changed Original file line number Diff line number Diff line change @@ -8,39 +8,39 @@ iland.api module
8
8
----------------
9
9
10
10
.. automodule :: iland.api
11
- :members:
12
- :undoc-members:
13
- :show-inheritance:
11
+ :members:
12
+ :undoc-members:
13
+ :show-inheritance:
14
14
15
15
iland.constant module
16
16
---------------------
17
17
18
18
.. automodule :: iland.constant
19
- :members:
20
- :undoc-members:
21
- :show-inheritance:
19
+ :members:
20
+ :undoc-members:
21
+ :show-inheritance:
22
22
23
23
iland.exception module
24
24
----------------------
25
25
26
26
.. automodule :: iland.exception
27
- :members:
28
- :undoc-members:
29
- :show-inheritance:
27
+ :members:
28
+ :undoc-members:
29
+ :show-inheritance:
30
30
31
31
iland.log module
32
32
----------------
33
33
34
34
.. automodule :: iland.log
35
- :members:
36
- :undoc-members:
37
- :show-inheritance:
35
+ :members:
36
+ :undoc-members:
37
+ :show-inheritance:
38
38
39
39
40
40
Module contents
41
41
---------------
42
42
43
43
.. automodule :: iland
44
- :members:
45
- :undoc-members:
46
- :show-inheritance:
44
+ :members:
45
+ :undoc-members:
46
+ :show-inheritance:
Original file line number Diff line number Diff line change 7
7
8
8
import requests
9
9
10
- from .constant import BASE_URL , ACCESS_URL , REFRESH_URL
11
- from .log import LOG
10
+ from .constant import ACCESS_URL , BASE_URL , REFRESH_URL
12
11
from .exception import ApiException , UnauthorizedException
12
+ from .log import LOG
13
13
14
14
15
15
class Api (object ):
Original file line number Diff line number Diff line change @@ -9,17 +9,17 @@ class ApiException(Exception):
9
9
@property
10
10
def error (self ):
11
11
"""Returns the first argument used to construct this error."""
12
- return self .args [0 ]
12
+ return self .args [0 ]. get ( 'type' )
13
13
14
14
@property
15
15
def message (self ):
16
16
"""Returns the second argument used to construct this error."""
17
- return self .args [1 ]
17
+ return self .args [0 ]. get ( 'message' )
18
18
19
19
@property
20
20
def detail_message (self ):
21
21
"""Returns the third argument used to construct this error."""
22
- return self .args [2 ]
22
+ return self .args [0 ]. get ( 'detail_message' )
23
23
24
24
25
25
class UnauthorizedException (ApiException ):
Original file line number Diff line number Diff line change 6
6
import time
7
7
import unittest
8
8
9
- import requests_mock
10
-
11
9
import iland
12
10
11
+ import requests_mock
12
+
13
13
BASE_URL = 'http://example.com/ecs'
14
14
15
15
VALID_TOKEN_PAYLOAD = {'expires_in' : 12 ,
Original file line number Diff line number Diff line change @@ -143,6 +143,17 @@ def test_api_errors(self):
143
143
with self .assertRaises (ApiException ):
144
144
self ._api .get ('/doesnotexist' )
145
145
146
+ def test_api_exception_properties (self ):
147
+ with self .assertRaises (ApiException ) as e :
148
+ self ._api .get ('/doesnotexist' )
149
+ api_exception = e .exception
150
+ self .assertEqual (api_exception .error ,
151
+ 'NotFoundError' )
152
+ self .assertEqual (api_exception .message ,
153
+ 'The specified resource does not exist.' )
154
+ self .assertIn ('Could not find resource for full path' ,
155
+ api_exception .detail_message )
156
+
146
157
@unittest .skipIf (not PROXIES , "No proxies defined" )
147
158
def test_get_with_proxy (self ):
148
159
self ._api ._proxies = PROXIES
You can’t perform that action at this time.
0 commit comments