3
3
import pytest
4
4
from requests .exceptions import RequestException
5
5
6
- from wowapi import WowApi , WowApiException
6
+ from wowapi import WowApi , WowApiException , WowApiOauthException
7
7
8
8
from .fixtures import ResponseMock
9
9
@@ -124,15 +124,16 @@ def test_get_resource_no_access_token(self, session_get_mock, utc_mock):
124
124
ResponseMock ()(200 , b'{"access_token": "111", "expires_in": 60}' ),
125
125
ResponseMock ()(200 , b'{"response": "ok"}' ),
126
126
]
127
- data = self .api .get_resource ('foo' , 'eu' )
128
-
129
- assert data == {'response' : 'ok' }
130
- assert self .api ._access_tokens == {
131
- 'eu' : {
132
- 'token' : '111' ,
133
- 'expiration' : now + timedelta (seconds = 60 )
127
+ with pytest .raises (WowApiOauthException ):
128
+ data = self .api .get_resource ('foo' , 'eu' )
129
+
130
+ assert data == {'response' : 'ok' }
131
+ assert self .api ._access_tokens == {
132
+ 'eu' : {
133
+ 'token' : '111' ,
134
+ 'expiration' : now + timedelta (seconds = 60 )
135
+ }
134
136
}
135
- }
136
137
137
138
def test_get_resource_no_access_expired (self , session_get_mock , utc_mock ):
138
139
now = datetime .utcnow ()
@@ -149,15 +150,16 @@ def test_get_resource_no_access_expired(self, session_get_mock, utc_mock):
149
150
ResponseMock ()(200 , b'{"access_token": "333", "expires_in": 60}' ),
150
151
ResponseMock ()(200 , b'{"response": "ok"}' ),
151
152
]
152
- data = self .api .get_resource ('foo' , 'eu' )
153
-
154
- assert data == {'response' : 'ok' }
155
- assert self .api ._access_tokens == {
156
- 'eu' : {
157
- 'token' : '333' ,
158
- 'expiration' : now + timedelta (seconds = 60 )
153
+ with pytest .raises (WowApiOauthException ):
154
+ data = self .api .get_resource ('foo' , 'eu' )
155
+
156
+ assert data == {'response' : 'ok' }
157
+ assert self .api ._access_tokens == {
158
+ 'eu' : {
159
+ 'token' : '333' ,
160
+ 'expiration' : now + timedelta (seconds = 60 )
161
+ }
159
162
}
160
- }
161
163
162
164
def test_format_base_url (self ):
163
165
assert self .api ._format_base_url ('test' , 'us' ) == 'https://us.api.blizzard.com/test'
0 commit comments