From 329bfae1ecad8ce5c61816724b81c309196bb61c Mon Sep 17 00:00:00 2001 From: Michael Lazar Date: Wed, 9 Dec 2015 01:34:55 -0800 Subject: [PATCH] Added unit tests for banner. --- tests/test_submission.py | 8 ++++++++ tests/test_subreddit.py | 8 ++++++++ tests/test_subscription.py | 10 ++++++++++ 3 files changed, 26 insertions(+) diff --git a/tests/test_submission.py b/tests/test_submission.py index 0deff58..5dab8e3 100644 --- a/tests/test_submission.py +++ b/tests/test_submission.py @@ -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') diff --git a/tests/test_subreddit.py b/tests/test_subreddit.py index 6305ab9..26a1e71 100644 --- a/tests/test_subreddit.py +++ b/tests/test_subreddit.py @@ -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) diff --git a/tests/test_subscription.py b/tests/test_subscription.py index c01a925..c54265e 100644 --- a/tests/test_subscription.py +++ b/tests/test_subscription.py @@ -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)