Updating tests

This commit is contained in:
Michael Lazar
2017-09-14 00:27:18 -04:00
parent 7e2d3c16ea
commit c1f3eb447a
5 changed files with 3426 additions and 47 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -75,22 +75,6 @@ def test_page_unauthenticated(reddit, terminal, config, oauth):
page.controller.trigger('?') page.controller.trigger('?')
assert Popen.called assert Popen.called
# Sort content - normal page
page.content.query = ''
page.controller.trigger('1')
page.refresh_content.assert_called_with(order='hot')
page.controller.trigger('3')
page.refresh_content.assert_called_with(order='rising')
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 = [ logged_in_methods = [
'a', # Upvote 'a', # Upvote
'z', # Downvote 'z', # Downvote

View File

@@ -173,36 +173,16 @@ def test_submission_prompt_submission(submission_page, terminal, prompt):
assert submission_page.content.order is None assert submission_page.content.order is None
def test_submission_order_top(submission_page, terminal): def test_submission_order(submission_page):
# Open the menu submission_page.controller.trigger('1')
with mock.patch.object(terminal, 'show_notification'): assert submission_page.content.order == 'hot'
# Invalid selection
terminal.show_notification.return_value = ord('x')
submission_page.controller.trigger('2') submission_page.controller.trigger('2')
terminal.show_notification.assert_called_with('Invalid option') assert submission_page.content.order == 'top'
assert submission_page.content.order is None submission_page.controller.trigger('3')
assert submission_page.content.order == 'rising'
# Valid selection - sort by week submission_page.controller.trigger('4')
terminal.show_notification.reset_mock() assert submission_page.content.order == 'new'
terminal.show_notification.return_value = ord('3')
submission_page.controller.trigger('2')
assert submission_page.content.order == 'top-week'
def test_submission_order_controversial(submission_page, terminal):
# Open the menu
with mock.patch.object(terminal, 'show_notification'):
# Invalid selection
terminal.show_notification.return_value = ord('x')
submission_page.controller.trigger('5')
terminal.show_notification.assert_called_with('Invalid option')
assert submission_page.content.order is None
# Valid selection - sort by default
terminal.show_notification.reset_mock()
terminal.show_notification.return_value = ord('\n')
submission_page.controller.trigger('5') submission_page.controller.trigger('5')
assert submission_page.content.order == 'controversial' assert submission_page.content.order == 'controversial'

View File

@@ -185,6 +185,23 @@ def test_subreddit_prompt_submission_invalid(subreddit_page, terminal):
assert isinstance(terminal.loader.exception, NotFound) assert isinstance(terminal.loader.exception, NotFound)
def test_subreddit_order(subreddit_page):
subreddit_page.content.query = ''
subreddit_page.controller.trigger('1')
assert subreddit_page.content.order == 'hot'
subreddit_page.controller.trigger('3')
assert subreddit_page.content.order == 'rising'
subreddit_page.controller.trigger('4')
assert subreddit_page.content.order == 'new'
subreddit_page.content.query = 'search text'
subreddit_page.controller.trigger('1')
assert subreddit_page.content.order == 'relevance'
subreddit_page.controller.trigger('4')
assert subreddit_page.content.order == 'new'
def test_subreddit_order_top(subreddit_page, terminal): def test_subreddit_order_top(subreddit_page, terminal):
# Sort by top # Sort by top