Updating tests
This commit is contained in:
1132
tests/cassettes/test_submission_order.yaml
Normal file
1132
tests/cassettes/test_submission_order.yaml
Normal file
File diff suppressed because it is too large
Load Diff
2266
tests/cassettes/test_subreddit_order.yaml
Normal file
2266
tests/cassettes/test_subreddit_order.yaml
Normal file
File diff suppressed because it is too large
Load Diff
@@ -75,22 +75,6 @@ def test_page_unauthenticated(reddit, terminal, config, oauth):
|
||||
page.controller.trigger('?')
|
||||
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 = [
|
||||
'a', # Upvote
|
||||
'z', # Downvote
|
||||
|
||||
@@ -173,38 +173,18 @@ def test_submission_prompt_submission(submission_page, terminal, prompt):
|
||||
assert submission_page.content.order is None
|
||||
|
||||
|
||||
def test_submission_order_top(submission_page, terminal):
|
||||
def test_submission_order(submission_page):
|
||||
|
||||
# Open the menu
|
||||
with mock.patch.object(terminal, 'show_notification'):
|
||||
# Invalid selection
|
||||
terminal.show_notification.return_value = ord('x')
|
||||
submission_page.controller.trigger('2')
|
||||
terminal.show_notification.assert_called_with('Invalid option')
|
||||
assert submission_page.content.order is None
|
||||
|
||||
# Valid selection - sort by week
|
||||
terminal.show_notification.reset_mock()
|
||||
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')
|
||||
assert submission_page.content.order == 'controversial'
|
||||
submission_page.controller.trigger('1')
|
||||
assert submission_page.content.order == 'hot'
|
||||
submission_page.controller.trigger('2')
|
||||
assert submission_page.content.order == 'top'
|
||||
submission_page.controller.trigger('3')
|
||||
assert submission_page.content.order == 'rising'
|
||||
submission_page.controller.trigger('4')
|
||||
assert submission_page.content.order == 'new'
|
||||
submission_page.controller.trigger('5')
|
||||
assert submission_page.content.order == 'controversial'
|
||||
|
||||
|
||||
def test_submission_move_top_bottom(submission_page):
|
||||
|
||||
@@ -185,6 +185,23 @@ def test_subreddit_prompt_submission_invalid(subreddit_page, terminal):
|
||||
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):
|
||||
|
||||
# Sort by top
|
||||
|
||||
Reference in New Issue
Block a user