Adding tests
This commit is contained in:
2723
tests/cassettes/test_subreddit_order_search.yaml
Normal file
2723
tests/cassettes/test_subreddit_order_search.yaml
Normal file
File diff suppressed because it is too large
Load Diff
@@ -75,7 +75,8 @@ def test_page_unauthenticated(reddit, terminal, config, oauth):
|
||||
page.controller.trigger('?')
|
||||
assert Popen.called
|
||||
|
||||
# Sort content
|
||||
# Sort content - normal page
|
||||
page.content.query = ''
|
||||
page.controller.trigger('1')
|
||||
page.refresh_content.assert_called_with(order='hot')
|
||||
page.controller.trigger('3')
|
||||
@@ -83,6 +84,13 @@ def test_page_unauthenticated(reddit, terminal, config, oauth):
|
||||
page.controller.trigger('4')
|
||||
page.refresh_content.assert_called_with(order='new')
|
||||
|
||||
# Sort content - search results
|
||||
page.content.query = 'search text'
|
||||
page.controller.trigger('1')
|
||||
page.refresh_content.assert_called_with(order='relevance')
|
||||
page.controller.trigger('4')
|
||||
page.refresh_content.assert_called_with(order='new')
|
||||
|
||||
logged_in_methods = [
|
||||
'a', # Upvote
|
||||
'z', # Downvote
|
||||
|
||||
@@ -560,7 +560,7 @@ def test_copy_to_clipboard_linux(submission_page, terminal, refresh_token):
|
||||
assert data.get('permalink') == content
|
||||
window.addstr.assert_called_with(1, 1, b'Copied permalink to clipboard')
|
||||
else:
|
||||
# Nither xclip or xsel installed, this is what happens on Travis CI
|
||||
# Neither xclip or xsel installed, this is what happens on Travis CI
|
||||
text = b'Failed to copy permalink: External copy application not found'
|
||||
window.addstr.assert_called_with(1, 1, text)
|
||||
|
||||
@@ -571,6 +571,6 @@ def test_copy_to_clipboard_linux(submission_page, terminal, refresh_token):
|
||||
assert data.get('url_full') == content
|
||||
window.addstr.assert_called_with(1, 1, b'Copied url to clipboard')
|
||||
else:
|
||||
# Nither xclip or xsel installed, this is what happens on Travis CI
|
||||
# Neither xclip or xsel installed, this is what happens on Travis CI
|
||||
text = b'Failed to copy url: External copy application not found'
|
||||
window.addstr.assert_called_with(1, 1, text)
|
||||
|
||||
@@ -196,6 +196,39 @@ def test_subreddit_order_controversial(subreddit_page, terminal):
|
||||
assert subreddit_page.content.order == 'controversial'
|
||||
|
||||
|
||||
def test_subreddit_order_search(subreddit_page, terminal):
|
||||
|
||||
# Search the current subreddit
|
||||
with mock.patch.object(terminal, 'prompt_input'):
|
||||
terminal.prompt_input.return_value = 'search term'
|
||||
subreddit_page.controller.trigger('f')
|
||||
assert subreddit_page.content.name == '/r/python'
|
||||
assert terminal.prompt_input.called
|
||||
assert not terminal.loader.exception
|
||||
|
||||
# Sort by relevance
|
||||
subreddit_page.controller.trigger('1')
|
||||
assert subreddit_page.content.order == 'relevance'
|
||||
|
||||
# Sort by top
|
||||
with mock.patch.object(terminal, 'show_notification'):
|
||||
terminal.show_notification.reset_mock()
|
||||
terminal.show_notification.return_value = ord('6')
|
||||
subreddit_page.controller.trigger('2')
|
||||
assert subreddit_page.content.order == 'top-all'
|
||||
|
||||
# Sort by comments
|
||||
with mock.patch.object(terminal, 'show_notification'):
|
||||
terminal.show_notification.reset_mock()
|
||||
terminal.show_notification.return_value = ord('6')
|
||||
subreddit_page.controller.trigger('3')
|
||||
assert subreddit_page.content.order == 'comments-all'
|
||||
|
||||
# Sort by new
|
||||
subreddit_page.controller.trigger('4')
|
||||
assert subreddit_page.content.order == 'new'
|
||||
|
||||
|
||||
def test_subreddit_open(subreddit_page, terminal, config):
|
||||
|
||||
# Open the selected submission
|
||||
|
||||
Reference in New Issue
Block a user