Added urlview keybinding
1. A shortcut of 'b' was used as the default binding for passing comment body text to urlview (this is similar to the default of C-b in the 'mutt' text email client) 2. The `comment_urlview` SubmissionController function was added to recieve the SUBMISSION_OPEN_IN_URLVIEWER keypress request. 3. The `open_urlview` terminal function was added to handle the urlview request. It passes the comment body data to urlview via a Popen process. 4. A test case was added to ensure this new code path is executed 5. Small formatting changes, mostly line length
This commit is contained in:
@@ -253,4 +253,29 @@ def test_submission_edit(submission_page, terminal, refresh_token):
|
||||
|
||||
submission_page.controller.trigger('e')
|
||||
assert open_editor.called
|
||||
edit.assert_called_with('comment text')
|
||||
edit.assert_called_with('comment text')
|
||||
|
||||
|
||||
def test_submission_urlview(submission_page, terminal, refresh_token):
|
||||
|
||||
# Log in
|
||||
submission_page.config.refresh_token = refresh_token
|
||||
submission_page.oauth.authorize()
|
||||
|
||||
# Positive Case
|
||||
data = submission_page.content.get(submission_page.nav.absolute_index)
|
||||
TEST_BODY = 'test comment body'
|
||||
data['body'] = TEST_BODY
|
||||
with mock.patch.object(terminal, 'open_urlview') as open_urlview, \
|
||||
mock.patch('subprocess.Popen'):
|
||||
submission_page.controller.trigger('b')
|
||||
open_urlview.assert_called_with(TEST_BODY)
|
||||
|
||||
# Negative Case
|
||||
data = submission_page.content.get(submission_page.nav.absolute_index)
|
||||
TEST_NO_BODY = ''
|
||||
data['body'] = TEST_NO_BODY
|
||||
with mock.patch.object(terminal, 'open_urlview') as open_urlview, \
|
||||
mock.patch('subprocess.Popen'):
|
||||
submission_page.controller.trigger('b')
|
||||
assert not open_urlview.called
|
||||
|
||||
Reference in New Issue
Block a user