From 9cfa44c7263b0926634581086af6bf300185ded4 Mon Sep 17 00:00:00 2001 From: Michael Lazar Date: Wed, 20 Jul 2016 21:28:24 -0700 Subject: [PATCH] Minor style changes. --- CONTROLS.rst | 3 +-- rtv/docs.py | 2 +- rtv/subreddit.py | 9 ++++----- tests/test_subreddit.py | 2 ++ 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CONTROLS.rst b/CONTROLS.rst index 6de2f42..f92ac1c 100644 --- a/CONTROLS.rst +++ b/CONTROLS.rst @@ -41,8 +41,7 @@ In subreddit mode you can browse through the top submissions on either the front :``o`` or ``ENTER``: Open the submission link with your web browser :``/``: Open a prompt to switch subreddits :``f``: Open a prompt to search the current subreddit -:``p``: Toggles between FrontPage and last visited subreddit - +:``p``: Toggle between the front page and the last visited subreddit The ``/`` prompt accepts subreddits in the following formats diff --git a/rtv/docs.py b/rtv/docs.py index 5facd30..40ee171 100644 --- a/rtv/docs.py +++ b/rtv/docs.py @@ -39,7 +39,7 @@ HELP = """ `l` or `RIGHT` : Enter the selected submission `/` : Open a prompt to switch subreddits `f` : Open a prompt to search the current subreddit - 'p' : Toggles between FrontPage and last visited subreddit + 'p' : Toggle between the front page and last visited subreddit [Submission Mode] `h` or `LEFT` : Return to subreddit mode diff --git a/rtv/subreddit.py b/rtv/subreddit.py index 95001b1..81046a4 100644 --- a/rtv/subreddit.py +++ b/rtv/subreddit.py @@ -77,20 +77,19 @@ class SubredditPage(Page): @SubredditController.register(Command('SUBREDDIT_FRONTPAGE')) def show_frontpage(self): """ - If on a subreddit, remeber it and head back to the front page. + If on a subreddit, remember it and head back to the front page. If this was pressed on the front page, go back to the last subreddit. """ - target ='' if not self.content.name == '/r/front': target = '/r/front' self._toggled_subreddit = self.content.name else: target = self._toggled_subreddit - # target still may be emptystring if this command hasn't yet been used - if not target == None: - self.refresh_content(order='ignore',name=target) + # target still may be empty string if this command hasn't yet been used + if target is not None: + self.refresh_content(order='ignore', name=target) @SubredditController.register(Command('SUBREDDIT_OPEN')) def open_submission(self, url=None): diff --git a/tests/test_subreddit.py b/tests/test_subreddit.py index 0a8a9f3..8ce4898 100644 --- a/tests/test_subreddit.py +++ b/tests/test_subreddit.py @@ -227,7 +227,9 @@ def test_subreddit_draw_header(subreddit_page, refresh_token, terminal): text = 'My Submissions'.encode('utf-8') terminal.stdscr.subwin.addstr.assert_any_call(0, 0, text) + def test_subreddit_frontpage_toggle(subreddit_page, terminal): + with mock.patch.object(terminal, 'prompt_input'): terminal.prompt_input.return_value = 'aww' subreddit_page.controller.trigger('/')