Automatically delete refresh-token if it is corrupted

This commit is contained in:
Michael Lazar
2017-06-08 01:04:29 -04:00
parent ca0f3f78ae
commit 979726ec6b
4 changed files with 88 additions and 4 deletions

View File

@@ -4,6 +4,7 @@ from __future__ import unicode_literals
import requests
from rtv.oauth import OAuthHelper, OAuthHandler
from rtv.exceptions import InvalidRefreshToken
from rtv.packages.praw.errors import OAuthException
@@ -75,6 +76,15 @@ def test_oauth_terminal_mobile_authorize(reddit, terminal, config):
assert '.compact' in oauth.reddit.config.API_PATHS['authorize']
def test_oauth_authorize_invalid_token(oauth, terminal):
oauth.config.refresh_token = 'invalid_token'
oauth.authorize()
assert oauth.server 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):
oauth.config.refresh_token = refresh_token