Added unit tests for banner.

This commit is contained in:
Michael Lazar
2015-12-09 01:34:55 -08:00
parent 9de6056b04
commit 329bfae1ec
3 changed files with 26 additions and 0 deletions

View File

@@ -28,6 +28,14 @@ def test_submission_page_construct(reddit, terminal, config, oauth):
title = url[:terminal.stdscr.ncols-1].encode('utf-8')
window.addstr.assert_any_call(0, 0, title)
# Banner
menu = ('[1]hot '
'[2]top '
'[3]rising '
'[4]new '
'[5]controversial').encode('utf-8')
window.addstr.assert_any_call(0, 0, menu)
# Submission
submission_data = page.content.get(-1)
text = submission_data['title'].encode('utf-8')

View File

@@ -21,6 +21,14 @@ def test_subreddit_page_construct(reddit, terminal, config, oauth):
title = '/r/python'.encode('utf-8')
window.addstr.assert_any_call(0, 0, title)
# Banner
menu = ('[1]hot '
'[2]top '
'[3]rising '
'[4]new '
'[5]controversial').encode('utf-8')
window.addstr.assert_any_call(0, 0, menu)
# Submission
text = page.content.get(0)['split_title'][0].encode('utf-8')
window.subwin.addstr.assert_any_call(0, 1, text, 2097152)

View File

@@ -4,6 +4,7 @@ from __future__ import unicode_literals
import curses
import praw
import pytest
from rtv.subscription import SubscriptionPage
@@ -41,6 +42,15 @@ def test_subscription_page_construct(reddit, terminal, config, oauth,
name = reddit.user.name.encode('utf-8')
window.addstr.assert_any_call(0, 59, name)
# Banner shouldn't be drawn
menu = ('[1]hot '
'[2]top '
'[3]rising '
'[4]new '
'[5]controversial').encode('utf-8')
with pytest.raises(AssertionError):
window.addstr.assert_any_call(0, 0, menu)
# Cursor - 2 lines
window.subwin.chgat.assert_any_call(0, 0, 1, 262144)
window.subwin.chgat.assert_any_call(1, 0, 1, 262144)