Merge branch 'master' into woorst-imgur_api
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -136,9 +136,10 @@ def test_config_from_file():
|
||||
|
||||
fargs, fbindings = Config.get_file(filename=fp.name)
|
||||
config = Config(**fargs)
|
||||
default_keymap = config.keymap._keymap.copy()
|
||||
config.keymap.set_bindings(fbindings)
|
||||
assert config.config == {}
|
||||
assert config.keymap._keymap == {}
|
||||
assert config.keymap._keymap == default_keymap
|
||||
|
||||
# [rtv]
|
||||
rows = ['{0}={1}'.format(key, val) for key, val in args.items()]
|
||||
@@ -224,4 +225,4 @@ def test_config_history():
|
||||
|
||||
config.delete_history()
|
||||
assert len(config.history) == 0
|
||||
assert not os.path.exists(fp.name)
|
||||
assert not os.path.exists(fp.name)
|
||||
|
||||
@@ -370,13 +370,17 @@ def test_objects_keymap():
|
||||
keymap.get('downvote')
|
||||
assert 'DOWNVOTE' in six.text_type(e)
|
||||
|
||||
# Updating the bindings wipes out the old ones
|
||||
bindings = {'refresh': ['a', 0x12, '<LF>', '<KEY_UP>']}
|
||||
bindings2 = {'upvote': ['b', 0x13, '<KEY_DOWN>']}
|
||||
keymap._keymap = {}
|
||||
keymap.set_bindings(bindings)
|
||||
assert keymap.get('refresh')
|
||||
with pytest.raises(exceptions.ConfigError) as e:
|
||||
keymap.get('upvote')
|
||||
assert 'UPVOTE' in six.text_type(e)
|
||||
keymap.set_bindings(bindings2)
|
||||
assert keymap.get('refresh')
|
||||
assert keymap.get('upvote')
|
||||
|
||||
# Strings should be parsed correctly into keys
|
||||
assert KeyMap.parse('a') == 97
|
||||
@@ -589,4 +593,4 @@ def test_objects_navigator_flip():
|
||||
nav.flip(3)
|
||||
assert nav.page_index == 2
|
||||
assert nav.cursor_index == 3
|
||||
assert not nav.inverted
|
||||
assert not nav.inverted
|
||||
|
||||
@@ -119,4 +119,4 @@ def test_page_authenticated(reddit, terminal, config, oauth, refresh_token):
|
||||
# Logout
|
||||
terminal.stdscr.getch.return_value = ord('y')
|
||||
page.controller.trigger('u')
|
||||
assert not reddit.is_oauth_session()
|
||||
assert not reddit.is_oauth_session()
|
||||
|
||||
@@ -87,6 +87,7 @@ def test_subreddit_title(subreddit_page, terminal, capsys):
|
||||
|
||||
|
||||
def test_subreddit_search(subreddit_page, terminal):
|
||||
window = terminal.stdscr.subwin
|
||||
|
||||
# Search the current subreddit
|
||||
with mock.patch.object(terminal, 'prompt_input'):
|
||||
@@ -96,12 +97,31 @@ def test_subreddit_search(subreddit_page, terminal):
|
||||
assert terminal.prompt_input.called
|
||||
assert not terminal.loader.exception
|
||||
|
||||
# The page title should display the query
|
||||
subreddit_page.draw()
|
||||
title = 'Searching /r/python: search term'.encode('utf-8')
|
||||
window.addstr.assert_any_call(0, 0, title)
|
||||
|
||||
# Ordering the results should preserve the query
|
||||
window.addstr.reset_mock()
|
||||
subreddit_page.refresh_content(order='hot')
|
||||
subreddit_page.refresh_content(order='top-all')
|
||||
subreddit_page.refresh_content(order='new')
|
||||
assert subreddit_page.content.name == '/r/python'
|
||||
assert subreddit_page.content.query == 'search term'
|
||||
assert not terminal.loader.exception
|
||||
|
||||
# Searching with an empty query shouldn't crash
|
||||
with mock.patch.object(terminal, 'prompt_input'):
|
||||
terminal.prompt_input.return_value = None
|
||||
subreddit_page.controller.trigger('f')
|
||||
assert not terminal.loader.exception
|
||||
|
||||
# Changing to a new subreddit should clear the query
|
||||
window.addstr.reset_mock()
|
||||
subreddit_page.refresh_content(name='/r/learnpython')
|
||||
assert subreddit_page.content.query is None
|
||||
|
||||
|
||||
def test_subreddit_prompt(subreddit_page, terminal):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user