Better support for random subreddit.

This commit is contained in:
Michael Lazar
2016-04-08 01:31:55 -07:00
parent fc8d70f06d
commit 8fc93911c6
3 changed files with 1364 additions and 0 deletions

View File

@@ -405,6 +405,9 @@ class SubredditContent(Content):
}
else:
subreddit = reddit.get_subreddit(name)
# For special subreddits like /r/random we want to replace the
# display name with the one returned by the request.
display_name = '/r/{0}'.format(subreddit.display_name)
dispatch = {
None: subreddit.get_hot,
'hot': subreddit.get_hot,

File diff suppressed because it is too large Load Diff

View File

@@ -274,6 +274,14 @@ def test_content_subreddit_multireddit(reddit, terminal):
assert isinstance(terminal.loader.exception, praw.errors.NotFound)
def test_content_subreddit_random(reddit, terminal):
name = '/r/random'
content = SubredditContent.from_name(reddit, name, terminal.loader)
assert content.name.startswith('/r/')
assert content.name != name
def test_content_subreddit_me(reddit, oauth, refresh_token, terminal):
# Not logged in