Working on adding pager.
This commit is contained in:
@@ -94,6 +94,23 @@ def test_submission_open(submission_page, terminal):
|
||||
assert terminal.open_browser.called
|
||||
|
||||
|
||||
def test_submission_pager(submission_page, terminal):
|
||||
|
||||
# View a submission with the pager
|
||||
with mock.patch.object(terminal, 'open_pager'):
|
||||
submission_page.controller.trigger(terminal.RETURN)
|
||||
assert terminal.open_browser.called
|
||||
|
||||
# Move down to the first comment
|
||||
with mock.patch.object(submission_page, 'clear_input_queue'):
|
||||
submission_page.controller.trigger('j')
|
||||
|
||||
# View a comment with the pager
|
||||
with mock.patch.object(terminal, 'open_pager'):
|
||||
submission_page.controller.trigger(terminal.RETURN)
|
||||
assert terminal.open_browser.called
|
||||
|
||||
|
||||
def test_submission_vote(submission_page, refresh_token):
|
||||
|
||||
# Log in
|
||||
|
||||
@@ -308,4 +308,26 @@ def test_open_browser(terminal):
|
||||
terminal.open_browser(url)
|
||||
open_new_tab.assert_called_with(url)
|
||||
assert curses.endwin.called
|
||||
assert curses.doupdate.called
|
||||
assert curses.doupdate.called
|
||||
|
||||
|
||||
def test_open_pager(terminal, stdscr):
|
||||
|
||||
data = "Hello World!"
|
||||
|
||||
def side_effect(*_, stdin=None):
|
||||
assert stdin is not None
|
||||
raise OSError
|
||||
|
||||
with mock.patch('subprocess.Popen', autospec=True) as Popen, \
|
||||
mock.patch.dict('os.environ', {'PAGER': 'fake'}):
|
||||
|
||||
terminal.open_pager(data)
|
||||
assert Popen.called
|
||||
assert not stdscr.addstr.called
|
||||
|
||||
# Raise an OS error
|
||||
Popen.side_effect = side_effect
|
||||
terminal.open_pager(data)
|
||||
message = 'Could not open pager fake'.encode('ascii')
|
||||
assert stdscr.addstr.called_with(0, 0, message)
|
||||
Reference in New Issue
Block a user