Fixing a test

This commit is contained in:
Michael Lazar
2017-06-08 01:12:57 -04:00
parent 979726ec6b
commit 690971355c
2 changed files with 68 additions and 34 deletions

View File

@@ -1,8 +1,6 @@
interactions: interactions:
- request: - request:
body: !!binary | body: grant_type=refresh_token&redirect_uri=http%3A%2F%2F127.0.0.1%3A65000%2F&refresh_token=**********
cmVkaXJlY3RfdXJpPWh0dHAlM0ElMkYlMkYxMjcuMC4wLjElM0E2NTAwMCUyRiZncmFudF90eXBl
PXJlZnJlc2hfdG9rZW4mcmVmcmVzaF90b2tlbj0qKioqKioqKioq
headers: headers:
Accept: ['*/*'] Accept: ['*/*']
Accept-Encoding: ['gzip, deflate'] Accept-Encoding: ['gzip, deflate']
@@ -10,28 +8,36 @@ interactions:
Connection: [keep-alive] Connection: [keep-alive]
Content-Length: ['122'] Content-Length: ['122']
Content-Type: [application/x-www-form-urlencoded] Content-Type: [application/x-www-form-urlencoded]
User-Agent: [rtv test suite PRAW/3.3.0 Python/3.4.0 b'Linux-3.13.0-24-generic-x86_64-with-Ubuntu-14.04-trusty'] User-Agent: [rtv test suite PRAW/3.6.1 Python/3.6.1 b'Darwin-14.5.0-x86_64-i386-64bit']
method: POST method: POST
uri: https://api.reddit.com/api/v1/access_token/ uri: https://api.reddit.com/api/v1/access_token/
response: response:
body: body: {string: '{"access_token": "nugDVOaY-ZXvTGCjjAo2-xxlx6M", "token_type":
string: !!binary | "bearer", "device_id": "None", "expires_in": 3600, "scope": "edit history
H4sIAAAAAAAAAyWMwWrDMBAFf2XROQEbJ6bk2mI3EHBzbC9Gsl6TpTgSuxtTUfrvxenpwTDzfpyf identity mysubreddits privatemessages read report save submit subscribe vote"}'}
JqiOlr5wcwdyu137VNX1ftsPL+m5Ow357fz+2eSu7oePvn3153B0G3KPYLSSsVYBXiArx3dmgY68
vjVtVW3I6ZT+NUQ2urJakkIccTO2QnPRexDEyKaUhRdvmKHqL1AS+EiCnMRI/QLSe5jZ1tFJOICW
ZHC/f8fwa1rKAAAA
headers: headers:
CF-RAY: [24e5686084e51e7d-SJC] Accept-Ranges: [bytes]
Connection: [keep-alive] Connection: [keep-alive]
Content-Encoding: [gzip] Content-Length: ['214']
Content-Type: [application/json; charset=UTF-8] Content-Type: [application/json; charset=UTF-8]
Date: ['Wed, 02 Dec 2015 07:44:38 GMT'] Date: ['Thu, 08 Jun 2017 05:10:45 GMT']
Server: [cloudflare-nginx] Server: [snooserv]
Set-Cookie: ['__cfduid=d97dd5b69ae5538390d1e4ad773c2b04e1449042278; expires=Thu, Set-Cookie: ['session_tracker=elCnnvdZ89Whx990FE.0.1496898645726.Z0FBQUFBQlpPTnhWSHF1V1ZpMXlISm5iTDY2Tk1jakVyODJKZXAxVUlsMkFfTkZPT29SMGQwUExKd2RWUUFVR19KQlNlbDQ5SlJlRHFFd1VYNVBzbE9xNDNiM2NGYmpJUUhicnNnb1ItMXBscmN0anBkV1VrdHU5Vkd4a2FrN1pCR05SRmFDY0xKd2Q;
01-Dec-16 07:44:38 GMT; path=/; domain=.reddit.com; HttpOnly'] Domain=reddit.com; Max-Age=7199; Path=/; expires=Thu, 08-Jun-2017 07:10:45
GMT; secure', edgebucket=x5yF0PW8TP96v0Q0Fb; Domain=reddit.com; Max-Age=63071999;
Path=/; secure]
Strict-Transport-Security: [max-age=15552000; includeSubDomains; preload] Strict-Transport-Security: [max-age=15552000; includeSubDomains; preload]
Via: [1.1 varnish]
X-Cache: [MISS]
X-Cache-Hits: ['0']
X-Moose: [majestic] X-Moose: [majestic]
X-Served-By: [cache-ord1747-ORD]
X-Timer: ['S1496898646.708198,VS0,VE38']
cache-control: ['max-age=0, must-revalidate'] cache-control: ['max-age=0, must-revalidate']
set-cookie: ['session_tracker=elCnnvdZ89Whx990FE.0.1496898645726.Z0FBQUFBQlpPTnhWSHF1V1ZpMXlISm5iTDY2Tk1jakVyODJKZXAxVUlsMkFfTkZPT29SMGQwUExKd2RWUUFVR19KQlNlbDQ5SlJlRHFFd1VYNVBzbE9xNDNiM2NGYmpJUUhicnNnb1ItMXBscmN0anBkV1VrdHU5Vkd4a2FrN1pCR05SRmFDY0xKd2Q;
Domain=reddit.com; Max-Age=7199; Path=/; expires=Thu, 08-Jun-2017 07:10:45
GMT; secure', edgebucket=x5yF0PW8TP96v0Q0Fb; Domain=reddit.com; Max-Age=63071999;
Path=/; secure]
x-content-type-options: [nosniff] x-content-type-options: [nosniff]
x-frame-options: [SAMEORIGIN] x-frame-options: [SAMEORIGIN]
x-xss-protection: [1; mode=block] x-xss-protection: [1; mode=block]
@@ -43,36 +49,61 @@ interactions:
Accept-Encoding: ['gzip, deflate'] Accept-Encoding: ['gzip, deflate']
Authorization: ['**********'] Authorization: ['**********']
Connection: [keep-alive] Connection: [keep-alive]
User-Agent: [rtv test suite PRAW/3.3.0 Python/3.4.0 b'Linux-3.13.0-24-generic-x86_64-with-Ubuntu-14.04-trusty'] User-Agent: [rtv test suite PRAW/3.6.1 Python/3.6.1 b'Darwin-14.5.0-x86_64-i386-64bit']
method: GET method: GET
uri: https://oauth.reddit.com/api/v1/me.json uri: https://oauth.reddit.com/api/v1/me.json
response: response:
body: body:
string: !!binary | string: !!binary |
H4sIAAAAAAAAA12QwWrDMBBEf0Xs2YTYuLTxZ5TSq5CtdbNE2k1XUhoI/fei1C5xjxp23ozmBkeX H4sIAFfcOFkC/4VVy27cOgz9lcDroMhM09tBd11kW6D3BwhZpm1hZFFXkmcyKfrvl5TlWE6CdjfD
bHQUYDCzCwkbA+wiwmDgFb2n/IYaiV14J/xChcbApOgyehhM2/fd89O+Oxx2+8bAkTzaWSValVFy h3h4eEj/akwEnLylG2Lz7a5XNuL9XdOjSnPAyKZfTUfgKEEKSp/ZkMIsIXGkK6jJgzWuMltzQRiV
emBSsqmkM7K/G1d5QdmSpxXXtf2Kq9XE/68XiE/25DS6aqkQiRE5/2nVKxdU275sG3xI8Fslykao 9+iMGzjxuvlUFzFcMEBATyGxv8rDQekbRFRBj+AD9vWbUYJBso1GCFx29pt/otZYhCu2kFQYcP9y
D/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hOeDieSgJfznKU19rr
Z2Xt+yRh0gF3xuo129b8/h9AQdmk+wgAAA==
headers: headers:
CF-RAY: [24e5686b66a111a7-SJC] Accept-Ranges: [bytes]
Connection: [keep-alive] Connection: [keep-alive]
Content-Encoding: [gzip] Content-Encoding: [gzip]
Content-Length: ['937']
Content-Type: [application/json; charset=UTF-8] Content-Type: [application/json; charset=UTF-8]
Date: ['Wed, 02 Dec 2015 07:44:40 GMT'] Date: ['Thu, 08 Jun 2017 05:10:47 GMT']
Server: [cloudflare-nginx] Server: [snooserv]
Set-Cookie: ['__cfduid=dae4a6a80cbf9100c339be2eeca35c7bc1449042280; expires=Thu, Set-Cookie: ['session_tracker=yytOV4DWjAg23Vztwx.0.1496898647536.Z0FBQUFBQlpPTnhYaDhibjVGdWFrTmpMZnZ1c1p3WHlHZnk4YkJWQXNLSHJsUEh1QVlUaXJmbk1ad285eVMzcG9vcVF6TVVOS3JPNTVndWFjZlUzSG0ycUVrTjFBWWhEZmxJeGpNa011dkU1c2J4TVVrSE5tWk9sbnI2NTlzWkFuV0hVMFFqWmhZb2Q;
01-Dec-16 07:44:40 GMT; path=/; domain=.reddit.com; HttpOnly'] Domain=reddit.com; Max-Age=7199; Path=/; expires=Thu, 08-Jun-2017 07:10:47
GMT; secure', edgebucket=sZ3YYMijQGbCPl8Utx; Domain=reddit.com; Max-Age=63071999;
Path=/; secure]
Strict-Transport-Security: [max-age=15552000; includeSubDomains; preload] Strict-Transport-Security: [max-age=15552000; includeSubDomains; preload]
Vary: [accept-encoding]
Via: [1.1 varnish]
X-Cache: [MISS]
X-Cache-Hits: ['0']
X-Moose: [majestic] X-Moose: [majestic]
cache-control: ['private, s-maxage=0, max-age=0, must-revalidate', 'max-age=0, X-Served-By: [cache-ord1737-ORD]
X-Timer: ['S1496898648.522802,VS0,VE47']
cache-control: ['private, s-maxage=0, max-age=0, must-revalidate, max-age=0,
must-revalidate'] must-revalidate']
expires: ['-1'] expires: ['-1']
set-cookie: ['session_tracker=yytOV4DWjAg23Vztwx.0.1496898647536.Z0FBQUFBQlpPTnhYaDhibjVGdWFrTmpMZnZ1c1p3WHlHZnk4YkJWQXNLSHJsUEh1QVlUaXJmbk1ad285eVMzcG9vcVF6TVVOS3JPNTVndWFjZlUzSG0ycUVrTjFBWWhEZmxJeGpNa011dkU1c2J4TVVrSE5tWk9sbnI2NTlzWkFuV0hVMFFqWmhZb2Q;
Domain=reddit.com; Max-Age=7199; Path=/; expires=Thu, 08-Jun-2017 07:10:47
GMT; secure', edgebucket=sZ3YYMijQGbCPl8Utx; Domain=reddit.com; Max-Age=63071999;
Path=/; secure]
x-content-type-options: [nosniff] x-content-type-options: [nosniff]
x-frame-options: [SAMEORIGIN] x-frame-options: [SAMEORIGIN]
x-ratelimit-remaining: ['595.0'] x-ratelimit-remaining: ['599.0']
x-ratelimit-reset: ['320'] x-ratelimit-reset: ['553']
x-ratelimit-used: ['5'] x-ratelimit-used: ['1']
x-xss-protection: [1; mode=block] x-xss-protection: [1; mode=block]
status: {code: 200, message: OK} status: {code: 200, message: OK}
version: 1 version: 1

View File

@@ -76,13 +76,14 @@ def test_oauth_terminal_mobile_authorize(reddit, terminal, config):
assert '.compact' in oauth.reddit.config.API_PATHS['authorize'] assert '.compact' in oauth.reddit.config.API_PATHS['authorize']
def test_oauth_authorize_invalid_token(oauth, terminal): def test_oauth_authorize_invalid_token(oauth):
oauth.config.refresh_token = 'invalid_token' oauth.config.refresh_token = 'invalid_token'
oauth.authorize() oauth.authorize()
assert isinstance(oauth.term.loader.exception, InvalidRefreshToken)
assert oauth.server is None assert oauth.server is None
assert oauth.config.refresh_token is None assert oauth.config.refresh_token is None
assert isinstance(terminal.loader.exception, InvalidRefreshToken)
def test_oauth_authorize_with_refresh_token(oauth, refresh_token): def test_oauth_authorize_with_refresh_token(oauth, refresh_token):
@@ -96,8 +97,10 @@ def test_oauth_authorize_with_refresh_token(oauth, refresh_token):
exception = OAuthException('', '') exception = OAuthException('', '')
oauth.reddit.refresh_access_information.side_effect = exception oauth.reddit.refresh_access_information.side_effect = exception
oauth.authorize() oauth.authorize()
assert isinstance(oauth.term.loader.exception, OAuthException)
assert isinstance(oauth.term.loader.exception, InvalidRefreshToken)
assert oauth.server is None assert oauth.server is None
assert oauth.config.refresh_token is None
def test_oauth_clear_data(oauth): def test_oauth_clear_data(oauth):