Skip to content

Commit

Permalink
Clear cache before betamax tests and move get_flairlist test.
Browse files Browse the repository at this point in the history
  • Loading branch information
bboe committed Apr 12, 2015
1 parent aa14b70 commit 9306ba5
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 12 deletions.
7 changes: 7 additions & 0 deletions praw/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,13 @@ def clear_timeouts():
return result
return wrapped

@classmethod
def clear_cache(cls):
"""Remove all items from the cache."""
with cls.ca_lock:
cls.cache = {}
cls.timeouts = {}

@classmethod
def evict(cls, urls):
"""Remove items from cache matching URL.
Expand Down
8 changes: 3 additions & 5 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ def travis_suite():
Until all tests are betamax compatible, this subset of tests is necessary.
"""
load = unittest.defaultTestLoader.loadTestsFromNames
tests = load(['tests.test_unauthenticated_reddit',
'tests.test_oauth2_reddit',
'tests.test_subreddit'])
return tests
import glob
return unittest.defaultTestLoader.loadTestsFromNames(
x[:-3].replace('/', '.') for x in glob.glob('tests/test_*.py'))
2 changes: 1 addition & 1 deletion tests/cassettes/test_get_flair_list.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"http_interactions": [{"request": {"body": {"string": "passwd=1111&user=PyAPITestUser2&api_type=json", "encoding": "utf-8"}, "headers": {"Content-Length": ["45"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "User-Agent": ["PRAW_test_suite PRAW/2.1.21 Python/2.7.5 Darwin-13.4.0-x86_64-i386-64bit"], "Connection": ["keep-alive"], "Content-Type": ["application/x-www-form-urlencoded"]}, "method": "POST", "uri": "https://ssl.reddit.com/api/login/.json"}, "response": {"body": {"base64_string": "H4sIAAAAAAAAAxzLTW7CMBBA4atYszaSZ2yPHZ+DXVWh8R+hFIySsAHl7hXdvk/vDT/ruENSb2jLMpYVkvr61gqqbPKf763V07xtjw91+V2bVnAbdZZ1hqTgyZHP1/zKrzAFoYm4oJt8NNE0j9IJSxEOFF0J3CqjB62gjHG9tM8frKHIQZNBfzDugOZINhEm9DoWjhm5oxVnO1lx3Vo2XK3POTvh3iYfyMC+738AAAD//wMAls4fs8oAAAA=", "encoding": "UTF-8"}, "headers": {"x-xss-protection": ["1; mode=block"], "x-content-type-options": ["nosniff"], "content-encoding": ["gzip"], "transfer-encoding": ["chunked"], "set-cookie": ["__cfduid=dffb28afb7fa36dd529ee3a0501f70ece1428733274; expires=Sun, 10-Apr-16 06:21:14 GMT; path=/; domain=.reddit.com; HttpOnly, secure_session=; Domain=reddit.com; Max-Age=-1428733275; Path=/; expires=Thu, 01-Jan-1970 00:00:01 GMT; HttpOnly, reddit_session=7302867%2C2015-04-10T23%3A21%3A15%2C8c68b16f13a43f23a4f33606d35bbb4a6fe95720; Domain=reddit.com; Path=/; HttpOnly"], "server": ["cloudflare-nginx"], "connection": ["keep-alive"], "x-ua-compatible": ["IE=edge"], "pragma": ["no-cache"], "cache-control": ["no-cache, no-cache"], "date": ["Sat, 11 Apr 2015 06:21:15 GMT"], "x-frame-options": ["SAMEORIGIN"], "x-moose": ["majestic"], "content-type": ["application/json; charset=UTF-8"], "cf-ray": ["1d54971672710663-SJC"]}, "status": {"message": "OK", "code": 200}, "url": "https://ssl.reddit.com/api/login/.json"}, "recorded_at": "2015-04-11T06:21:24"}, {"request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"Connection": ["keep-alive"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "User-Agent": ["PRAW_test_suite PRAW/2.1.21 Python/2.7.5 Darwin-13.4.0-x86_64-i386-64bit"]}, "method": "GET", "uri": "http://www.reddit.com/subreddits/mine/moderator/.json?limit=1024"}, "response": {"body": {"string": "<html>\n <head>\n <title>302 Found</title>\n </head>\n <body>\n <h1>302 Found</h1>\n The resource was found at <a href=\"http://www.reddit.com/subreddits/login.json?dest=http%3A%2F%2Fwww.reddit.com%2Fsubreddits%2Fmine%2Fmoderator%2F.json%3Flimit%3D1024\">http://www.reddit.com/subreddits/login.json?dest=http%3A%2F%2Fwww.reddit.com%2Fsubreddits%2Fmine%2Fmoderator%2F.json%3Flimit%3D1024</a>;\nyou should be redirected automatically.\n\n\n </body>\n</html>", "encoding": "UTF-8"}, "headers": {"x-xss-protection": ["1; mode=block"], "x-reddit-tracking": ["https://pixel.redditmedia.com/pixel/of_destiny.png?v=PV%2BEMu5xCc8ZX%2BGXYfuaca2wrmEtKlcNBYo6ex7N%2BBbFC2ft47uV9c2vCQZXPSF84yspOtPQTTE%3D"], "x-content-type-options": ["nosniff"], "access-control-expose-headers": ["X-Reddit-Tracking, X-Moose"], "transfer-encoding": ["chunked"], "set-cookie": ["__cfduid=d596ab6b4d44368151843e08e071ea58d1428733275; expires=Sun, 10-Apr-16 06:21:15 GMT; path=/; domain=.reddit.com; HttpOnly"], "cf-cache-status": ["EXPIRED"], "vary": ["Accept-Encoding"], "x-moose": ["majestic"], "cf-ray": ["1d54971e1bad0d8b-SJC"], "connection": ["keep-alive"], "x-ua-compatible": ["IE=edge"], "cache-control": ["no-cache"], "date": ["Sat, 11 Apr 2015 06:21:15 GMT"], "x-frame-options": ["SAMEORIGIN"], "server": ["cloudflare-nginx"], "content-type": ["text/html; charset=UTF-8"], "access-control-allow-origin": ["*"], "location": ["http://www.reddit.com/subreddits/login.json?dest=http%3A%2F%2Fwww.reddit.com%2Fsubreddits%2Fmine%2Fmoderator%2F.json%3Flimit%3D1024"]}, "status": {"message": "Found", "code": 302}, "url": "http://www.reddit.com/subreddits/mine/moderator/.json?limit=1024"}, "recorded_at": "2015-04-11T06:21:25"}], "recorded_with": "betamax/0.4.1"}
{"http_interactions": [{"request": {"body": {"string": "passwd=1111&user=PyAPITestUser2&api_type=json", "encoding": "utf-8"}, "headers": {"Content-Length": ["45"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "User-Agent": ["PRAW_test_suite PRAW/2.1.21 Python/2.7.5 Darwin-13.4.0-x86_64-i386-64bit"], "Connection": ["keep-alive"], "Content-Type": ["application/x-www-form-urlencoded"]}, "method": "POST", "uri": "https://ssl.reddit.com/api/login/.json"}, "response": {"body": {"base64_string": "H4sIAAAAAAAAAxzL0U7DMAxA0V+J/JxJdmyaJt/BG0LI1I5KGQtqqw0x9d/ReL1H9w7L1i9Qwx18Xfu6QQ0vrzGA6a7/+eJub/O+fz+o6XnzGOCr26zbDDWA8O/P7bws6WplNNLCE5UsqekoxiUzuQ5YWJI0G8QzQQww9f754Y8/M6ZxyDEhPZ1QTpSeiSvlKhKVWxHBYtjMJm6FBkqi6uj0ThmbTZnGhHAcxx8AAAD//wMAKSHy/coAAAA=", "encoding": "UTF-8"}, "headers": {"x-xss-protection": ["1; mode=block"], "x-content-type-options": ["nosniff"], "content-encoding": ["gzip"], "transfer-encoding": ["chunked"], "set-cookie": ["__cfduid=de63d4185d4bfb30f6d57f16c8bb926f41428869863; expires=Mon, 11-Apr-16 20:17:43 GMT; path=/; domain=.reddit.com; HttpOnly, secure_session=; Domain=reddit.com; Max-Age=-1428869864; Path=/; expires=Thu, 01-Jan-1970 00:00:01 GMT; HttpOnly, reddit_session=7302867%2C2015-04-12T13%3A17%3A44%2Ca3f94409d0fddc3f916124aae0e1b170fdc71820; Domain=reddit.com; Path=/; HttpOnly"], "server": ["cloudflare-nginx"], "connection": ["keep-alive"], "x-ua-compatible": ["IE=edge"], "pragma": ["no-cache"], "cache-control": ["no-cache, no-cache"], "date": ["Sun, 12 Apr 2015 20:17:44 GMT"], "x-frame-options": ["SAMEORIGIN"], "x-moose": ["majestic"], "content-type": ["application/json; charset=UTF-8"], "cf-ray": ["1d619dc9dabf11e9-SJC"]}, "status": {"message": "OK", "code": 200}, "url": "https://ssl.reddit.com/api/login/.json"}, "recorded_at": "2015-04-12T20:17:45"}, {"request": {"body": {"string": "passwd=1111&uh=43zxwljj2vd98d1a93c19742fa84d39731ea6093424fd64e71&user=PyAPITestUser2&api_type=json", "encoding": "utf-8"}, "headers": {"Content-Length": ["99"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "User-Agent": ["PRAW_test_suite PRAW/2.1.21 Python/2.7.5 Darwin-13.4.0-x86_64-i386-64bit"], "Connection": ["keep-alive"], "Content-Type": ["application/x-www-form-urlencoded"]}, "method": "POST", "uri": "https://ssl.reddit.com/api/login/.json"}, "response": {"body": {"base64_string": "H4sIAAAAAAAAAxzLQW7DIBBA0augWRMJMzA4nKO7KKpmYJDbJqaxySry3at0+5/+C773vkI2L9Bt69sO2Vyu1kDlwf95Va2fyxi/b2p829UauPe68L5ANsDj4dZa4nOo1KTUsJAEVcRKZy81eC5KEhNxbMjtnMAaKL3/fOn7T+j8TMl6N8WTC6fJf0yYp5RDtBjRuVkEiXUmStoE58Q+lFiZEIsKehKB4zj+AAAA//8DAPD411LKAAAA", "encoding": "UTF-8"}, "headers": {"x-xss-protection": ["1; mode=block"], "x-content-type-options": ["nosniff"], "content-encoding": ["gzip"], "transfer-encoding": ["chunked"], "set-cookie": ["__cfduid=da6b6f621f993c304c17784f4645f33261428869864; expires=Mon, 11-Apr-16 20:17:44 GMT; path=/; domain=.reddit.com; HttpOnly, secure_session=; Domain=reddit.com; Max-Age=-1428869865; Path=/; expires=Thu, 01-Jan-1970 00:00:01 GMT; HttpOnly, reddit_session=7302867%2C2015-04-12T13%3A17%3A45%2C353008bb36ae8667efb387a24c5da633ceb326bb; Domain=reddit.com; Path=/; HttpOnly"], "server": ["cloudflare-nginx"], "connection": ["keep-alive"], "x-ua-compatible": ["IE=edge"], "pragma": ["no-cache"], "cache-control": ["no-cache, no-cache"], "date": ["Sun, 12 Apr 2015 20:17:45 GMT"], "x-frame-options": ["SAMEORIGIN"], "x-moose": ["majestic"], "content-type": ["application/json; charset=UTF-8"], "cf-ray": ["1d619dcf3af711e9-SJC"]}, "status": {"message": "OK", "code": 200}, "url": "https://ssl.reddit.com/api/login/.json"}, "recorded_at": "2015-04-12T20:17:46"}, {"request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"Connection": ["keep-alive"], "Cookie": ["11-Apr-16 20:17:44 GMT; reddit_session=7302867%2C2015-04-12T13%3A17%3A45%2C353008bb36ae8667efb387a24c5da633ceb326bb"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "User-Agent": ["PRAW_test_suite PRAW/2.1.21 Python/2.7.5 Darwin-13.4.0-x86_64-i386-64bit"]}, "method": "GET", "uri": "http://www.reddit.com/subreddits/mine/moderator/.json?limit=1024"}, "response": {"body": {"base64_string": "H4sIAOrSKlUC/+1WXWvbMBT9K8ZPG3SJ7SSO07e2D11hg3bdyyhDyJJca5U/Il2nTUr++yRFTux03foBZYO9BHzv1TnnfhzIvX/DS+ofev4nroCX1/6B51MMWIfu/aKiOVa5SdcVh9U8nk8XQYbZNMZhkCTBLIrJLBiNgxEeBTQepRHBQTDOZlOcGCSSc0ElKzXC1f2WCiY9lhSXJZOIF9cmaVKqSQsOCNgdoBwKoeNlI4TONMpUKmTfGLAMC8V0glvkCCZVvIfQglKuaoGXqMQFMzHJKNUluOa6TIEpyRmmOyU5QH04HKYDyJsiVYPNg4JRjgekKob0x+JbdZRcXN8dwenx+cnHy+Tkdnk8rz7MTunF5eJu9Tk/zSQ08dmgdpNlikheA6/KvcaAg7CysqpKsbTDq4TAtWKIMsGAUaRJC1aC6rRdLZgMk06gblLBCXqciBMdUnxlyLqhzvjdGFpJrqoDubcnwcsbJHDKOjSYkKrRWhEmwBcdGCcQJM4yTjrKHauTdjUKggNP/3zf8BjulEnTexTtqO2J7FG3N6Kvl0kMldQpkI3haHcPE7Q9FSIZBntL4SiKJpNgOp0MAoMjDag/lMO9UxnaIXHKEKbdZTgk1IDpaw/NXXl/8q1UvQDQ/TU9sVo/qpksuFJ65oboysdC+GYiD9fc7sQdCVKkkgxZlQW3r40KPTbXDCxrO4oN0nablmubxOXSZFqZuz04lev1gfcmvr4NV/OX+RrVki8emPvhTT/mxy8Wzjs6P/O+ajjvncHTa37/71rUJl5rUFfdt2a4Y+w50zI+0Zftqru+nCRhkoyjP/jSrvqp5uxBPsOcLd4buXNzbC+wp9X5Zv5s8o3Jnu/P6BXe/BXUf0v2Lenu6lWWbLfbteQ4nOl/fkn4e0tGT7WjhkviqYP7a+0odUuSEzODdqzPdqRRhDOwIddayjLN777X65+tym7RlQsAAA==", "encoding": "UTF-8"}, "headers": {"content-length": ["727"], "x-xss-protection": ["1; mode=block"], "x-reddit-tracking": ["https://pixel.redditmedia.com/pixel/of_destiny.png?v=WU6gA3RGpZAIvyRyzjzzPApzneASDUMgjyb0RtvSrwUeJrYLWq4NgUABtaf2eNugS9CZSkV5s0Q%3D"], "x-content-type-options": ["nosniff"], "content-encoding": ["gzip"], "set-cookie": ["__cfduid=db0a4d68fdcd511d6c36301e9174c16651428869865; expires=Mon, 11-Apr-16 20:17:45 GMT; path=/; domain=.reddit.com; HttpOnly"], "vary": ["accept-encoding"], "x-ratelimit-remaining": ["299"], "x-moose": ["majestic"], "connection": ["keep-alive"], "x-ua-compatible": ["IE=edge"], "pragma": ["no-cache"], "cache-control": ["no-cache, no-cache"], "date": ["Sun, 12 Apr 2015 20:17:46 GMT"], "x-frame-options": ["SAMEORIGIN"], "server": ["cloudflare-nginx"], "content-type": ["application/json; charset=UTF-8"], "cf-ray": ["1d619dd57c2011d1-SJC"], "x-ratelimit-used": ["1"], "x-ratelimit-reset": ["135"]}, "status": {"message": "OK", "code": 200}, "url": "http://www.reddit.com/subreddits/mine/moderator/.json?limit=1024"}, "recorded_at": "2015-04-12T20:17:47"}, {"request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"Connection": ["keep-alive"], "Cookie": ["11-Apr-16 20:17:44 GMT; 11-Apr-16 20:17:45 GMT; reddit_session=7302867%2C2015-04-12T13%3A17%3A45%2C353008bb36ae8667efb387a24c5da633ceb326bb"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "User-Agent": ["PRAW_test_suite PRAW/2.1.21 Python/2.7.5 Darwin-13.4.0-x86_64-i386-64bit"]}, "method": "GET", "uri": "http://www.reddit.com/r/reddit_api_test/api/flairlist/.json"}, "response": {"body": {"base64_string": "H4sIAAAAAAAAA6pWKi1OLSpWslKIrlZKy0nMLIpPLi6OT85JLAYJKinpKIBVgNhFqSkpmSUgEYjCktSKEiTxWh0FbEbklebkIBkSUOkY4BmSWlwSWpxaZIRpWFp+flJiES7DlJJyEjOQ3YRinDGGcSDLa2NrAQAAAP//AwDhb6675gAAAA==", "encoding": "UTF-8"}, "headers": {"x-ratelimit-remaining": ["298"], "x-xss-protection": ["1; mode=block"], "x-reddit-tracking": ["https://pixel.redditmedia.com/pixel/of_destiny.png?v=AsNgi%2BR8ITgPiwH0SwNIkeQorhXGAAVkCc4w6YghC58gytGAZnSNUFiDaR90VJxaqKIEdC1D2f7z4mA8aM1UEnJBlU0yyNNq"], "x-content-type-options": ["nosniff"], "content-encoding": ["gzip"], "transfer-encoding": ["chunked"], "set-cookie": ["__cfduid=db6acc6a76b7dec21e704ba88389428501428869866; expires=Mon, 11-Apr-16 20:17:46 GMT; path=/; domain=.reddit.com; HttpOnly"], "x-moose": ["majestic"], "connection": ["keep-alive"], "x-ua-compatible": ["IE=edge"], "pragma": ["no-cache"], "cache-control": ["no-cache, no-cache"], "date": ["Sun, 12 Apr 2015 20:17:46 GMT"], "x-frame-options": ["SAMEORIGIN"], "server": ["cloudflare-nginx"], "content-type": ["application/json; charset=UTF-8"], "cf-ray": ["1d619dd8ccb011d1-SJC"], "x-ratelimit-used": ["2"], "x-ratelimit-reset": ["134"]}, "status": {"message": "OK", "code": 200}, "url": "http://www.reddit.com/r/reddit_api_test/api/flairlist/.json"}, "recorded_at": "2015-04-12T20:17:47"}], "recorded_with": "betamax/0.4.1"}

0 comments on commit 9306ba5

Please sign in to comment.