2
2
from datetime import datetime
3
3
4
4
import pytest
5
-
6
5
import responses
7
6
8
7
from twitch import TwitchHelix
112
111
"access_token" : "xxxxxx" ,
113
112
"expires_in" : 123456 ,
114
113
"token_type" : "bearer" ,
115
- "scope" :["analytics:read:extensions" ]
114
+ "scope" : ["analytics:read:extensions" ],
116
115
}
117
116
118
117
example_get_oauth_error_response = {
119
118
"status" : 400 ,
120
119
"message" : "missing client secret" ,
121
120
}
122
121
123
- example_get_oauth_bad_request = {
124
- "status" : 401
125
- }
122
+ example_get_oauth_bad_request = {"status" : 401 }
126
123
127
124
example_get_videos_response = {
128
125
"data" : [
@@ -215,6 +212,7 @@ def test_get_oauth_returns_oauth_token():
215
212
216
213
assert client ._oauth_token
217
214
215
+
218
216
@responses .activate
219
217
def test_get_oauth_returns_oauth_token_with_scopes ():
220
218
responses .add (
@@ -225,9 +223,12 @@ def test_get_oauth_returns_oauth_token_with_scopes():
225
223
content_type = "application/json" ,
226
224
)
227
225
228
- client = TwitchHelix ("client id" , client_secret = "client secret" ,scopes = ['analytics:read:extensions' ])
226
+ client = TwitchHelix (
227
+ "client id" , client_secret = "client secret" , scopes = ["analytics:read:extensions" ]
228
+ )
229
229
client .get_oauth ()
230
230
231
+
231
232
@responses .activate
232
233
def test_get_oauth_raises_oauth_exception_bad_request ():
233
234
responses .add (
@@ -238,10 +239,11 @@ def test_get_oauth_raises_oauth_exception_bad_request():
238
239
content_type = "application/json" ,
239
240
)
240
241
241
- client = TwitchHelix ("client id" ,client_secret = ' client secret' )
242
+ client = TwitchHelix ("client id" , client_secret = " client secret" )
242
243
with pytest .raises (TwitchOAuthException ):
243
244
client .get_oauth ()
244
245
246
+
245
247
@responses .activate
246
248
def test_get_oauth_raises_oauth_exception_worse_request ():
247
249
responses .add (
@@ -252,10 +254,11 @@ def test_get_oauth_raises_oauth_exception_worse_request():
252
254
content_type = "application/json" ,
253
255
)
254
256
255
- client = TwitchHelix ("client id" ,client_secret = ' client secret' )
257
+ client = TwitchHelix ("client id" , client_secret = " client secret" )
256
258
with pytest .raises (TwitchOAuthException ):
257
259
client .get_oauth ()
258
260
261
+
259
262
def test_get_oauth_raises_oauth_exception_missing_secret ():
260
263
client = TwitchHelix ("client id" )
261
264
with pytest .raises (TwitchOAuthException ):
0 commit comments