Adding tests
This commit is contained in:
@@ -282,7 +282,8 @@ class Terminal(object):
|
|||||||
|
|
||||||
row, col = window.getyx()
|
row, col = window.getyx()
|
||||||
_, max_cols = window.getmaxyx()
|
_, max_cols = window.getmaxyx()
|
||||||
if max_cols - col - 1 <= 0:
|
n_cols = max_cols - col - 1
|
||||||
|
if n_cols <= 0:
|
||||||
# Trying to draw outside of the screen bounds
|
# Trying to draw outside of the screen bounds
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -87,8 +87,8 @@ def test_submission_page_construct(reddit, terminal, config, oauth):
|
|||||||
window.subwin.addstr.assert_any_call(0, 1, text, curses.A_NORMAL)
|
window.subwin.addstr.assert_any_call(0, 1, text, curses.A_NORMAL)
|
||||||
|
|
||||||
# Cursor should not be drawn when the page is first opened
|
# Cursor should not be drawn when the page is first opened
|
||||||
# TODO: Add a new test for this
|
assert not any(args[0][3] == curses.A_REVERSE
|
||||||
# assert not window.subwin.chgat.called
|
for args in window.subwin.addch.call_args_list)
|
||||||
|
|
||||||
# Reload with a smaller terminal window
|
# Reload with a smaller terminal window
|
||||||
terminal.stdscr.ncols = 20
|
terminal.stdscr.ncols = 20
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import codecs
|
|||||||
import six
|
import six
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from rtv.theme import Theme
|
||||||
from rtv.docs import HELP, COMMENT_EDIT_FILE
|
from rtv.docs import HELP, COMMENT_EDIT_FILE
|
||||||
from rtv.exceptions import TemporaryFileError, BrowserError
|
from rtv.exceptions import TemporaryFileError, BrowserError
|
||||||
|
|
||||||
@@ -56,6 +57,8 @@ def test_terminal_properties(terminal, config):
|
|||||||
assert terminal.MIN_HEIGHT is not None
|
assert terminal.MIN_HEIGHT is not None
|
||||||
assert terminal.MIN_WIDTH is not None
|
assert terminal.MIN_WIDTH is not None
|
||||||
|
|
||||||
|
assert terminal.theme is not None
|
||||||
|
|
||||||
|
|
||||||
def test_terminal_functions(terminal):
|
def test_terminal_functions(terminal):
|
||||||
|
|
||||||
@@ -554,3 +557,42 @@ def test_strip_textpad(terminal):
|
|||||||
text = 'alpha bravo\ncharlie \ndelta \n echo \n\nfoxtrot\n\n\n'
|
text = 'alpha bravo\ncharlie \ndelta \n echo \n\nfoxtrot\n\n\n'
|
||||||
assert terminal.strip_textpad(text) == (
|
assert terminal.strip_textpad(text) == (
|
||||||
'alpha bravocharlie delta\n echo\n\nfoxtrot')
|
'alpha bravocharlie delta\n echo\n\nfoxtrot')
|
||||||
|
|
||||||
|
|
||||||
|
def test_add_space(terminal, stdscr):
|
||||||
|
|
||||||
|
stdscr.x, stdscr.y = 10, 20
|
||||||
|
terminal.add_space(stdscr)
|
||||||
|
stdscr.addstr.assert_called_with(20, 10, ' ')
|
||||||
|
|
||||||
|
# Not enough room to add a space
|
||||||
|
stdscr.reset_mock()
|
||||||
|
stdscr.x = 10
|
||||||
|
stdscr.ncols = 11
|
||||||
|
terminal.add_space(stdscr)
|
||||||
|
assert not stdscr.addstr.called
|
||||||
|
|
||||||
|
|
||||||
|
def test_attr(terminal):
|
||||||
|
|
||||||
|
assert terminal.attr('cursor') == 0
|
||||||
|
assert terminal.attr('cursor.selected') == curses.A_REVERSE
|
||||||
|
assert terminal.attr('neutral_vote') == curses.A_BOLD
|
||||||
|
|
||||||
|
with terminal.theme.set_modifier('selected'):
|
||||||
|
assert terminal.attr('cursor') == curses.A_REVERSE
|
||||||
|
assert terminal.attr('neutral_vote') == curses.A_BOLD
|
||||||
|
|
||||||
|
|
||||||
|
def test_set_theme(terminal, stdscr):
|
||||||
|
|
||||||
|
stdscr.reset_mock()
|
||||||
|
terminal.set_theme()
|
||||||
|
assert not terminal.theme.monochrome
|
||||||
|
stdscr.bkgd.assert_called_once_with(' ', 0)
|
||||||
|
|
||||||
|
stdscr.reset_mock()
|
||||||
|
theme = Theme(monochrome=True)
|
||||||
|
terminal.set_theme(theme=theme)
|
||||||
|
assert terminal.theme.monochrome
|
||||||
|
stdscr.bkgd.assert_called_once_with(' ', 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user