Working on tests

This commit is contained in:
Michael Lazar
2017-09-13 02:04:58 -04:00
parent 8c22d742f2
commit 5908d932f0
2 changed files with 7 additions and 3 deletions

View File

@@ -311,7 +311,8 @@ class OAuthRateLimitHandler(DefaultHandler):
else: else:
self.next_request_timestamp = None self.next_request_timestamp = None
@fix_cache(DefaultHandler.with_cache) @fix_cache
@DefaultHandler.with_cache
def request(self, request, proxies, timeout, verify, **_): def request(self, request, proxies, timeout, verify, **_):
settings = self.http.merge_environment_settings( settings = self.http.merge_environment_settings(

View File

@@ -12,7 +12,7 @@ from vcr import VCR
from six.moves.urllib.parse import urlparse, parse_qs from six.moves.urllib.parse import urlparse, parse_qs
from six.moves.BaseHTTPServer import HTTPServer from six.moves.BaseHTTPServer import HTTPServer
from rtv.oauth import OAuthHelper, OAuthHandler from rtv.oauth import OAuthHelper, OAuthHandler, OAuthRateLimitHandler
from rtv.config import Config from rtv.config import Config
from rtv.packages import praw from rtv.packages import praw
from rtv.terminal import Terminal from rtv.terminal import Terminal
@@ -180,9 +180,12 @@ def reddit(vcr, request):
with vcr.use_cassette(cassette_name): with vcr.use_cassette(cassette_name):
with patch('rtv.packages.praw.Reddit.get_access_information'): with patch('rtv.packages.praw.Reddit.get_access_information'):
handler = OAuthRateLimitHandler()
reddit = praw.Reddit(user_agent='rtv test suite', reddit = praw.Reddit(user_agent='rtv test suite',
decode_html_entities=False, decode_html_entities=False,
disable_update_check=True) disable_update_check=True,
handler=handler)
# praw uses a global cache for requests, so we need to clear it # praw uses a global cache for requests, so we need to clear it
# before each unit test. Otherwise we may fail to generate new # before each unit test. Otherwise we may fail to generate new
# cassettes. # cassettes.