Adding tests

This commit is contained in:
Michael Lazar
2017-08-31 10:51:59 -04:00
parent 03ef3c254d
commit 7fbc02b4a0
4 changed files with 2767 additions and 3 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -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

View File

@@ -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)

View File

@@ -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