Skip to content

Commit

Permalink
Update Redditor tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
bboe committed Apr 13, 2015
1 parent fd99710 commit e3340ae
Show file tree
Hide file tree
Showing 14 changed files with 90 additions and 72 deletions.
1 change: 0 additions & 1 deletion praw/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ def _prepare_request(reddit_session, url, params, data, auth, files):
if getattr(reddit_session, '_use_oauth', False):
headers = {'Authorization': 'bearer %s' % reddit_session.access_token}
config = reddit_session.config
# TODO: Verify this works as expected
for prefix in (config.api_url, config.permalink_url):
if url.startswith(prefix):
if config.log_requests >= 1:
Expand Down
8 changes: 4 additions & 4 deletions praw/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -851,8 +851,8 @@ class LoggedInRedditor(Redditor):

"""A class representing a currently logged in Redditor."""

get_hidden = restrict_access("history")(_get_redditor_listing('hidden'))
get_saved = restrict_access("history")(_get_redditor_listing('saved'))
get_hidden = restrict_access('history')(_get_redditor_listing('hidden'))
get_saved = restrict_access('history')(_get_redditor_listing('saved'))

def get_blocked(self):
"""Return a UserList of Redditors with whom the user has blocked."""
Expand All @@ -872,10 +872,10 @@ def get_cached_moderated_reddits(self):
self._mod_subs[six.text_type(sub).lower()] = sub
return self._mod_subs

def get_friends(self):
def get_friends(self, **params):
"""Return a UserList of Redditors with whom the user has friended."""
url = self.reddit_session.config['friends']
return self.reddit_session.request_json(url)[0]
return self.reddit_session.request_json(url, params=params)[0]


class ModAction(RedditContentObject):
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
author_email='timothy.mellor+pip@gmail.com',
maintainer='Bryce Boe',
maintainer_email='bbzbryce@gmail.com',
url='http://praw.readthedocs.org/',
url='https://praw.readthedocs.org/',
description=('PRAW, an acronym for `Python Reddit API Wrapper`, is a '
'python package that allows for simple access to '
'reddit\'s API.'),
Expand All @@ -46,7 +46,7 @@
packages=[PACKAGE_NAME],
package_data={'': ['COPYING'], PACKAGE_NAME: ['*.ini']},
dependency_links=[
'https://github.com/bboe/betamax/archive/ResponseCookies.zip#egg=betamax-0.4.1'],
'https://github.com/sigmavirus24/betamax/archive/46b6e8c8aa6ceca3c9ca662f90df35bd0c5ab75d.zip#egg=betamax-0.4.1'],
install_requires=['requests>=2.3.0', 'six>=1.4', 'update_checker>=0.11'],
tests_require=['betamax>=0.4.1', 'betamax-matchers>=0.1.0', 'mock>=1.0.0'],
entry_points={'console_scripts': [
Expand Down
1 change: 1 addition & 0 deletions tests/cassettes/test_add_remove_friends.json
Original file line number Diff line number Diff line change
@@ -0,0 +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/3.0a1 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://api.reddit.com/api/login/.json"}, "response": {"body": {"base64_string": "H4sIAAAAAAAAAxzLS2rEMBBF0a2IGquhVNbH0jp6FkKQVM84SccKtmeN9x4603u4T/o6xkbFPAn7PvaDinl7t4a0nvU/b4B+rOf5+6KlPg5YQz9D13qsVAztj7jNvscJggTkBplFWnMJSXIWCejMPKuLQPMKR9ZQH+P7E68/TSxzTFbYhRv7m5O7TMVL8cEGlQXwrrnMnCbtqYaoQF26pKAqWpHBla7r+gMAAP//AwDpMDkYygAAAA==", "encoding": "UTF-8"}, "headers": {"x-xss-protection": ["1; mode=block"], "x-content-type-options": ["nosniff"], "content-encoding": ["gzip"], "transfer-encoding": ["chunked"], "set-cookie": ["__cfduid=d447f28dfe821a8a0cd7d3cf818ec86381428907365; expires=Tue, 12-Apr-16 06:42:45 GMT; path=/; domain=.reddit.com; HttpOnly, secure_session=; Domain=reddit.com; Max-Age=-1428907365; Path=/; expires=Thu, 01-Jan-1970 00:00:01 GMT; HttpOnly, reddit_session=7302867%2C2015-04-12T23%3A42%3A45%2C5d2fee41b190073dc7a56deeafc275dd2dae9e0a; 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": ["Mon, 13 Apr 2015 06:42:45 GMT"], "x-frame-options": ["SAMEORIGIN"], "x-moose": ["majestic"], "content-type": ["application/json; charset=UTF-8"], "cf-ray": ["1d653158bd0c0293-SJC"]}, "cookies": "ccopy_reg\n_reconstructor\np0\n(crequests.cookies\nRequestsCookieJar\np1\nc__builtin__\nobject\np2\nNtp3\nRp4\n(dp5\nS'_now'\np6\nI1428907366\nsS'_policy'\np7\n(icookielib\nDefaultCookiePolicy\np8\n(dp9\nS'strict_rfc2965_unverifiable'\np10\nI01\nsS'strict_ns_domain'\np11\nI0\nsS'_allowed_domains'\np12\nNsS'rfc2109_as_netscape'\np13\nNsS'rfc2965'\np14\nI00\nsS'strict_domain'\np15\nI00\nsg6\nI1428907366\nsS'strict_ns_set_path'\np16\nI00\nsS'strict_ns_unverifiable'\np17\nI00\nsS'strict_ns_set_initial_dollar'\np18\nI00\nsS'hide_cookie2'\np19\nI00\nsS'_blocked_domains'\np20\n(tsS'netscape'\np21\nI01\nsbsS'_cookies'\np22\n(dp23\nS'.reddit.com'\np24\n(dp25\nS'/'\np26\n(dp27\nS'reddit_session'\np28\n(icookielib\nCookie\np29\n(dp30\nS'comment'\np31\nNsS'domain'\np32\nS'.reddit.com'\np33\nsS'name'\np34\ng28\nsS'domain_initial_dot'\np35\nI00\nsS'expires'\np36\nNsS'value'\np37\nS'7302867%2C2015-04-12T23%3A42%3A45%2C5d2fee41b190073dc7a56deeafc275dd2dae9e0a'\np38\nsS'domain_specified'\np39\nI01\nsS'_rest'\np40\n(dp41\nS'HttpOnly'\np42\nNssS'version'\np43\nI0\nsS'port_specified'\np44\nI00\nsS'rfc2109'\np45\nI00\nsS'discard'\np46\nI01\nsS'path_specified'\np47\nI01\nsS'path'\np48\ng26\nsS'port'\np49\nNsS'comment_url'\np50\nNsS'secure'\np51\nI00\nsbsS'__cfduid'\np52\n(icookielib\nCookie\np53\n(dp54\ng31\nNsg32\ng24\nsg34\ng52\nsg35\nI01\nsg36\nI1460443365\nsg37\nS'd447f28dfe821a8a0cd7d3cf818ec86381428907365'\np55\nsg39\nI01\nsg40\n(dp56\nS'HttpOnly'\np57\nNssg43\nI0\nsg44\nI00\nsg45\nI00\nsg46\nI00\nsg47\nI01\nsg48\ng26\nsg49\nNsg50\nNsg51\nI00\nsbssssb.", "status": {"message": "OK", "code": 200}, "url": "https://api.reddit.com/api/login/.json"}, "recorded_at": "2015-04-13T06:42:46"}, {"request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"Connection": ["keep-alive"], "Cookie": ["reddit_session=7302867%2C2015-04-12T23%3A42%3A45%2C5d2fee41b190073dc7a56deeafc275dd2dae9e0a; __cfduid=d447f28dfe821a8a0cd7d3cf818ec86381428907365"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "User-Agent": ["PRAW_test_suite PRAW/3.0a1 Python/2.7.5 Darwin-13.4.0-x86_64-i386-64bit"]}, "method": "GET", "uri": "https://api.reddit.com/prefs/friends/.json"}, "response": {"body": {"base64_string": "H4sIAAAAAAAAA4quVsrOzEtRslJQCi1OLfLJLC5R0lFQSkksSVSyUqhWSs7IzEkpSs1TslKIjq2t1VEgTX0sAAAA//8DADr5nXdgAAAA", "encoding": "UTF-8"}, "headers": {"x-ratelimit-remaining": ["299"], "x-xss-protection": ["1; mode=block"], "x-reddit-tracking": ["https://pixel.redditmedia.com/pixel/of_destiny.png?v=Yt5gBT0uQISfrkPTxscfvqCx1gKLOfucwizyBxl4%2FfFs%2B4gglFL1MigrPOfCcExGRV2XOE3AuoZSIxonn6pVTk5vVNM0iKDD"], "x-content-type-options": ["nosniff"], "content-encoding": ["gzip"], "transfer-encoding": ["chunked"], "server": ["cloudflare-nginx"], "connection": ["keep-alive"], "x-ua-compatible": ["IE=edge"], "pragma": ["no-cache"], "cache-control": ["no-cache, no-cache"], "date": ["Mon, 13 Apr 2015 06:42:46 GMT"], "x-frame-options": ["SAMEORIGIN"], "x-moose": ["majestic"], "content-type": ["application/json; charset=UTF-8"], "cf-ray": ["1d65315dad4a0293-SJC"], "x-ratelimit-used": ["1"], "x-ratelimit-reset": ["434"]}, "status": {"message": "OK", "code": 200}, "url": "https://api.reddit.com/prefs/friends/.json"}, "recorded_at": "2015-04-13T06:42:46"}, {"request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"Connection": ["keep-alive"], "Cookie": ["reddit_session=7302867%2C2015-04-12T23%3A42%3A45%2C5d2fee41b190073dc7a56deeafc275dd2dae9e0a; __cfduid=d447f28dfe821a8a0cd7d3cf818ec86381428907365"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "User-Agent": ["PRAW_test_suite PRAW/3.0a1 Python/2.7.5 Darwin-13.4.0-x86_64-i386-64bit"]}, "method": "GET", "uri": "https://api.reddit.com/user/PyAPITestUser2/about/.json"}, "response": {"body": {"base64_string": "H4sIAAAAAAAAA1SRy27DIBREfwWxtioTE8f2LsvusmjXiMd1fWsDFeAoaZR/r0B5dTuaGc5cLnRGZ+hAaNrQilAjk6QDudBJRmElLnQgo1wiVIQ6aSE7D+f94f0DYvqMEEoKoxgDQim6u3UAmSArbNPxlm3rbvtWV4ROaECMwVsRvPIpvmS+/GKEDmAMFj3brTeTjFN+WFklv2f9i2eu2E71u0b3pudNW+u+gVabtjOKd5qN26ape+B1hruBiDXpBwzjd5g805v71BTWzLGgm8Usg823YJtc4q0Flx5iXxHqjxAE654xjCIveBmEpf3pKAPh9INBJvSODsSty3LjOELAEcEI+E+D5X+4xtNYju2UPwntV5fyia7XPwAAAP//AwDjW3JlxAEAAA==", "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=0Rvkk6HR%2BId5J1iNXvI2c95UApZQ1Jn34t2ziITsSKE%2B0xSJUMgXJ4oakPB84u7eW%2Bwwdw%2B30Gk%3D"], "x-content-type-options": ["nosniff"], "content-encoding": ["gzip"], "transfer-encoding": ["chunked"], "server": ["cloudflare-nginx"], "connection": ["keep-alive"], "x-ua-compatible": ["IE=edge"], "pragma": ["no-cache"], "cache-control": ["no-cache, no-cache"], "date": ["Mon, 13 Apr 2015 06:42:46 GMT"], "x-frame-options": ["SAMEORIGIN"], "x-moose": ["majestic"], "content-type": ["application/json; charset=UTF-8"], "cf-ray": ["1d65315e9d6e0293-SJC"], "x-ratelimit-used": ["2"], "x-ratelimit-reset": ["434"]}, "status": {"message": "OK", "code": 200}, "url": "https://api.reddit.com/user/PyAPITestUser2/about/.json"}, "recorded_at": "2015-04-13T06:42:46"}, {"request": {"body": {"string": "uh=bmbajkcziy4b17b973c9d94360c93e6cd68db48c1f53309e40&container=t2_4cixf&type=friend&name=PyAPITestUser3&api_type=json", "encoding": "utf-8"}, "headers": {"Content-Length": ["118"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "User-Agent": ["PRAW_test_suite PRAW/3.0a1 Python/2.7.5 Darwin-13.4.0-x86_64-i386-64bit"], "Connection": ["keep-alive"], "Cookie": ["reddit_session=7302867%2C2015-04-12T23%3A42%3A45%2C5d2fee41b190073dc7a56deeafc275dd2dae9e0a; __cfduid=d447f28dfe821a8a0cd7d3cf818ec86381428907365"], "Content-Type": ["application/x-www-form-urlencoded"]}, "method": "POST", "uri": "https://api.reddit.com/api/unfriend/.json"}, "response": {"body": {"string": "{}", "encoding": "UTF-8"}, "headers": {"content-length": ["2"], "x-xss-protection": ["1; mode=block"], "x-content-type-options": ["nosniff"], "x-ratelimit-remaining": ["297"], "server": ["cloudflare-nginx"], "connection": ["keep-alive"], "x-ua-compatible": ["IE=edge"], "pragma": ["no-cache"], "cache-control": ["no-cache, no-cache"], "date": ["Mon, 13 Apr 2015 06:42:46 GMT"], "x-frame-options": ["SAMEORIGIN"], "x-moose": ["majestic"], "content-type": ["application/json; charset=UTF-8"], "cf-ray": ["1d6531606d940293-SJC"], "x-ratelimit-used": ["3"], "x-ratelimit-reset": ["434"]}, "status": {"message": "OK", "code": 200}, "url": "https://api.reddit.com/api/unfriend/.json"}, "recorded_at": "2015-04-13T06:42:46"}, {"request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"Connection": ["keep-alive"], "Cookie": ["reddit_session=7302867%2C2015-04-12T23%3A42%3A45%2C5d2fee41b190073dc7a56deeafc275dd2dae9e0a; __cfduid=d447f28dfe821a8a0cd7d3cf818ec86381428907365"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "User-Agent": ["PRAW_test_suite PRAW/3.0a1 Python/2.7.5 Darwin-13.4.0-x86_64-i386-64bit"]}, "method": "GET", "uri": "https://api.reddit.com/prefs/friends/.json?u=1"}, "response": {"body": {"base64_string": "H4sIAAAAAAAAA4quVsrOzEtRslJQCi1OLfLJLC5R0lFQSkksSVSyUqhWSs7IzEkpSs1TslKIjq2t1VEgTX0sAAAA//8DADr5nXdgAAAA", "encoding": "UTF-8"}, "headers": {"x-ratelimit-remaining": ["296"], "x-xss-protection": ["1; mode=block"], "x-reddit-tracking": ["https://pixel.redditmedia.com/pixel/of_destiny.png?v=BAiUumjcJ4Y60ut5x4fH%2FjhenwAJfiS05vHI2GEq0XYkN0w4A0kVdE2fkaUI0TLmySr5JDeszK%2FfT%2FJPziiZrIDGUaBMmbGV"], "x-content-type-options": ["nosniff"], "content-encoding": ["gzip"], "transfer-encoding": ["chunked"], "server": ["cloudflare-nginx"], "connection": ["keep-alive"], "x-ua-compatible": ["IE=edge"], "pragma": ["no-cache"], "cache-control": ["no-cache, no-cache"], "date": ["Mon, 13 Apr 2015 06:42:46 GMT"], "x-frame-options": ["SAMEORIGIN"], "x-moose": ["majestic"], "content-type": ["application/json; charset=UTF-8"], "cf-ray": ["1d653161dda80293-SJC"], "x-ratelimit-used": ["4"], "x-ratelimit-reset": ["434"]}, "status": {"message": "OK", "code": 200}, "url": "https://api.reddit.com/prefs/friends/.json?u=1"}, "recorded_at": "2015-04-13T06:42:47"}, {"request": {"body": {"string": "uh=bmbajkcziy4b17b973c9d94360c93e6cd68db48c1f53309e40&container=t2_4cixf&type=friend&name=PyAPITestUser3&api_type=json", "encoding": "utf-8"}, "headers": {"Content-Length": ["118"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "User-Agent": ["PRAW_test_suite PRAW/3.0a1 Python/2.7.5 Darwin-13.4.0-x86_64-i386-64bit"], "Connection": ["keep-alive"], "Cookie": ["reddit_session=7302867%2C2015-04-12T23%3A42%3A45%2C5d2fee41b190073dc7a56deeafc275dd2dae9e0a; __cfduid=d447f28dfe821a8a0cd7d3cf818ec86381428907365"], "Content-Type": ["application/x-www-form-urlencoded"]}, "method": "POST", "uri": "https://api.reddit.com/api/friend/.json"}, "response": {"body": {"string": "{\"json\": {\"errors\": []}}", "encoding": "UTF-8"}, "headers": {"content-length": ["24"], "x-xss-protection": ["1; mode=block"], "x-content-type-options": ["nosniff"], "x-ratelimit-remaining": ["295"], "server": ["cloudflare-nginx"], "connection": ["keep-alive"], "x-ua-compatible": ["IE=edge"], "pragma": ["no-cache"], "cache-control": ["no-cache, no-cache"], "date": ["Mon, 13 Apr 2015 06:42:46 GMT"], "x-frame-options": ["SAMEORIGIN"], "x-moose": ["majestic"], "content-type": ["application/json; charset=UTF-8"], "cf-ray": ["1d653162cdac0293-SJC"], "x-ratelimit-used": ["5"], "x-ratelimit-reset": ["434"]}, "status": {"message": "OK", "code": 200}, "url": "https://api.reddit.com/api/friend/.json"}, "recorded_at": "2015-04-13T06:42:47"}, {"request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"Connection": ["keep-alive"], "Cookie": ["reddit_session=7302867%2C2015-04-12T23%3A42%3A45%2C5d2fee41b190073dc7a56deeafc275dd2dae9e0a; __cfduid=d447f28dfe821a8a0cd7d3cf818ec86381428907365"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "User-Agent": ["PRAW_test_suite PRAW/3.0a1 Python/2.7.5 Darwin-13.4.0-x86_64-i386-64bit"]}, "method": "GET", "uri": "https://api.reddit.com/prefs/friends/.json?u=2"}, "response": {"body": {"base64_string": "H4sIAAAAAAAAA4quVsrOzEtRslJQCi1OLfLJLC5R0lFQSkksSVSyUqhWSs7IzEkpSs1TslKIrgYJpypZKRiaGFlYGpgbm5npGegoKOUl5oJElQIqHQM8Q1KLS0AmGYOMyQQbXGIUb5ZsWJGlVBtbW6ujQIKNsbW1sQAAAAD//wMAaeszdKIAAAA=", "encoding": "UTF-8"}, "headers": {"x-ratelimit-remaining": ["294"], "x-xss-protection": ["1; mode=block"], "x-reddit-tracking": ["https://pixel.redditmedia.com/pixel/of_destiny.png?v=GB1eMsoMszG3HSVqz0adJfAauehERjUc34ZpI7EHXg4zM9E7KlcMZviADkLWTZUpdpoOXktvi%2BHcTKdJcyzgOxG7LLHkvuV8"], "x-content-type-options": ["nosniff"], "content-encoding": ["gzip"], "transfer-encoding": ["chunked"], "server": ["cloudflare-nginx"], "connection": ["keep-alive"], "x-ua-compatible": ["IE=edge"], "pragma": ["no-cache"], "cache-control": ["no-cache, no-cache"], "date": ["Mon, 13 Apr 2015 06:42:47 GMT"], "x-frame-options": ["SAMEORIGIN"], "x-moose": ["majestic"], "content-type": ["application/json; charset=UTF-8"], "cf-ray": ["1d6531646db70293-SJC"], "x-ratelimit-used": ["6"], "x-ratelimit-reset": ["433"]}, "status": {"message": "OK", "code": 200}, "url": "https://api.reddit.com/prefs/friends/.json?u=2"}, "recorded_at": "2015-04-13T06:42:47"}, {"request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"Connection": ["keep-alive"], "Cookie": ["reddit_session=7302867%2C2015-04-12T23%3A42%3A45%2C5d2fee41b190073dc7a56deeafc275dd2dae9e0a; __cfduid=d447f28dfe821a8a0cd7d3cf818ec86381428907365"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "User-Agent": ["PRAW_test_suite PRAW/3.0a1 Python/2.7.5 Darwin-13.4.0-x86_64-i386-64bit"]}, "method": "GET", "uri": "https://api.reddit.com/user/PyAPITestUser3/about/.json"}, "response": {"body": {"base64_string": "H4sIAAAAAAAAA2SPwQrCMBBEfyXsuYhNqWBvHr150PMSm41d2ySQpKKU/rukoBa8PubNzk7Qs9PQCEgSCgFaJQWNmMApSxmfXofT8UwxXSKFKkc4oglMi5XCSIWANpBKlEFZSVnXcl9Xm20hoGNNaIK3GPzVpwiNMGqIKwfH1P57A7seexVsHlPmtLeWXPqyHOKINz/kq59Ojmj9GnQq4oMCGyaNZBUPv9G8vL1ry+cd5vkNAAD//wMAXEWPyQkBAAA=", "encoding": "UTF-8"}, "headers": {"x-ratelimit-remaining": ["293"], "x-xss-protection": ["1; mode=block"], "x-reddit-tracking": ["https://pixel.redditmedia.com/pixel/of_destiny.png?v=VwhW57lZ%2FF9hTXryo0KW%2Bjd5us07jWO0Qy3O%2BrOiWngF9Jn91r3udGKSEfOufw%2FK6852SMlJQpY%3D"], "x-content-type-options": ["nosniff"], "content-encoding": ["gzip"], "transfer-encoding": ["chunked"], "server": ["cloudflare-nginx"], "connection": ["keep-alive"], "x-ua-compatible": ["IE=edge"], "pragma": ["no-cache"], "cache-control": ["no-cache, no-cache"], "date": ["Mon, 13 Apr 2015 06:42:47 GMT"], "x-frame-options": ["SAMEORIGIN"], "x-moose": ["majestic"], "content-type": ["application/json; charset=UTF-8"], "cf-ray": ["1d6531655dbf0293-SJC"], "x-ratelimit-used": ["7"], "x-ratelimit-reset": ["433"]}, "status": {"message": "OK", "code": 200}, "url": "https://api.reddit.com/user/PyAPITestUser3/about/.json"}, "recorded_at": "2015-04-13T06:42:47"}], "recorded_with": "betamax/0.4.1"}

0 comments on commit e3340ae

Please sign in to comment.