Attempt to fix the tests

An attempt to fix the broken tests
This commit is contained in:
Edridge D'Souza
2018-07-16 16:52:08 -04:00
parent b2d3439faa
commit ad97b8ff9a
4 changed files with 26 additions and 3 deletions

View File

@@ -31,6 +31,7 @@ SUBREDDIT_PROMPTS = OrderedDict([
('top', ('pics/top', '/r/pics', 'top')), ('top', ('pics/top', '/r/pics', 'top')),
('rising', ('r/pics/rising', '/r/pics', 'rising')), ('rising', ('r/pics/rising', '/r/pics', 'rising')),
('controversial', ('/r/pics/controversial', '/r/pics', 'controversial')), ('controversial', ('/r/pics/controversial', '/r/pics', 'controversial')),
('gilded', ('/r/pics/gilded', '/r/pics', 'gilded'))
('top-day', ('/r/pics/top-day', '/r/pics', 'top-day')), ('top-day', ('/r/pics/top-day', '/r/pics', 'top-day')),
('top-hour', ('/r/pics/top-hour', '/r/pics', 'top-hour')), ('top-hour', ('/r/pics/top-hour', '/r/pics', 'top-hour')),
('top-month', ('/r/pics/top-month', '/r/pics', 'top-month')), ('top-month', ('/r/pics/top-month', '/r/pics', 'top-month')),

View File

@@ -62,7 +62,8 @@ def test_submission_page_construct(reddit, terminal, config, oauth):
'[2]top ' '[2]top '
'[3]rising ' '[3]rising '
'[4]new ' '[4]new '
'[5]controversial').encode('utf-8') '[5]controversial'
'[6]gilded ').encode('utf-8')
window.addstr.assert_any_call(0, 0, menu) window.addstr.assert_any_call(0, 0, menu)
# Footer # Footer
@@ -185,6 +186,8 @@ def test_submission_order(submission_page):
assert submission_page.content.order == 'new' assert submission_page.content.order == 'new'
submission_page.controller.trigger('5') submission_page.controller.trigger('5')
assert submission_page.content.order == 'controversial' assert submission_page.content.order == 'controversial'
submission_page.controller.trigger('6')
assert submission_page.content.order == 'gilded'
def test_submission_move_top_bottom(submission_page): def test_submission_move_top_bottom(submission_page):

View File

@@ -34,7 +34,8 @@ def test_subreddit_page_construct(reddit, terminal, config, oauth):
'[2]top ' '[2]top '
'[3]rising ' '[3]rising '
'[4]new ' '[4]new '
'[5]controversial').encode('utf-8') '[5]controversial'
'[6]gilded ').encode('utf-8')
window.addstr.assert_any_call(0, 0, menu) window.addstr.assert_any_call(0, 0, menu)
# Submission # Submission
@@ -243,6 +244,23 @@ def test_subreddit_order_controversial(subreddit_page, terminal):
assert subreddit_page.content.order == 'controversial' assert subreddit_page.content.order == 'controversial'
def test_subreddit_order_gilded(subreddit_page, terminal):
# Sort by controversial
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): def test_subreddit_order_search(subreddit_page, terminal):
# Search the current subreddit # Search the current subreddit

View File

@@ -40,7 +40,8 @@ def test_subscription_page_construct(reddit, terminal, config, oauth,
'[2]top ' '[2]top '
'[3]rising ' # Whitespace is relevant '[3]rising ' # Whitespace is relevant
'[4]new ' '[4]new '
'[5]controversial').encode('utf-8') '[5]controversial'
'[6]gilded ').encode('utf-8')
with pytest.raises(AssertionError): with pytest.raises(AssertionError):
window.addstr.assert_any_call(0, 0, menu) window.addstr.assert_any_call(0, 0, menu)