Fixing tests and adding cassettes

This commit is contained in:
Michael Lazar
2018-08-04 01:42:43 -04:00
parent b959b5d4bd
commit b8fb0cf418
8 changed files with 8866 additions and 2143 deletions

View File

@@ -190,6 +190,9 @@ def test_subreddit_prompt_submission_invalid(subreddit_page, terminal):
def test_subreddit_order(subreddit_page):
# /r/python doesn't always have rising submissions, so use a larger sub
subreddit_page.refresh_content(name='all')
subreddit_page.content.query = ''
subreddit_page.controller.trigger('1')
assert subreddit_page.content.order == 'hot'
@@ -197,6 +200,8 @@ def test_subreddit_order(subreddit_page):
assert subreddit_page.content.order == 'rising'
subreddit_page.controller.trigger('4')
assert subreddit_page.content.order == 'new'
subreddit_page.controller.trigger('6')
assert subreddit_page.content.order == 'gilded'
subreddit_page.content.query = 'search text'
subreddit_page.controller.trigger('1')
@@ -204,6 +209,11 @@ def test_subreddit_order(subreddit_page):
subreddit_page.controller.trigger('4')
assert subreddit_page.content.order == 'new'
# Shouldn't be able to sort queries by gilded
subreddit_page.controller.trigger('6')
assert curses.flash.called
assert subreddit_page.content.order == 'new'
def test_subreddit_order_top(subreddit_page, terminal):
@@ -239,23 +249,6 @@ def test_subreddit_order_controversial(subreddit_page, terminal):
assert subreddit_page.content.order == 'controversial'
# def test_subreddit_order_gilded(subreddit_page, terminal):
#
# # Sort by gilded
# with mock.patch.object(terminal, 'show_notification'):
# # Invalid selection
# terminal.show_notification.return_value = ord('x')
# subreddit_page.controller.trigger('6')
# terminal.show_notification.assert_called_with('Invalid option')
# assert subreddit_page.content.order is None
# # Valid selection - sort by default
# terminal.show_notification.reset_mock()
# terminal.show_notification.return_value = ord('\n')
# subreddit_page.controller.trigger('6')
# assert subreddit_page.content.order == 'gilded'
def test_subreddit_order_search(subreddit_page, terminal):
# Search the current subreddit