diff options
author | Miroslav <ttahabatt@gmail.com> | 2018-03-01 01:18:05 +0200 |
---|---|---|
committer | Miroslav <ttahabatt@gmail.com> | 2018-03-01 01:18:05 +0200 |
commit | d151c6c32230f71146b3b1215fc2b41a4e9e880d (patch) | |
tree | f6626fa592a3a609ff72eec1995e4cf00464ade8 /test | |
parent | 5161458217227123069911c4d2dae39fcb603720 (diff) | |
download | mitmproxy-d151c6c32230f71146b3b1215fc2b41a4e9e880d.tar.gz mitmproxy-d151c6c32230f71146b3b1215fc2b41a4e9e880d.tar.bz2 mitmproxy-d151c6c32230f71146b3b1215fc2b41a4e9e880d.zip |
Initial tests. New conditions.
Diffstat (limited to 'test')
-rw-r--r-- | test/mitmproxy/tools/console/test_statusbar.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/mitmproxy/tools/console/test_statusbar.py b/test/mitmproxy/tools/console/test_statusbar.py index db8a63a7..22bb761f 100644 --- a/test/mitmproxy/tools/console/test_statusbar.py +++ b/test/mitmproxy/tools/console/test_statusbar.py @@ -1,6 +1,8 @@ from mitmproxy import options from mitmproxy.tools.console import statusbar, master +from unittest import mock + def test_statusbar(monkeypatch): o = options.Options() @@ -31,3 +33,26 @@ def test_statusbar(monkeypatch): bar = statusbar.StatusBar(m) # this already causes a redraw assert bar.ib._w + + +def test_prep_message(): + o = options.Options() + m = master.ConsoleMaster(o) + m.ui = mock.MagicMock() + m.ui.get_cols_rows = mock.MagicMock(return_value=(50, 50)) + ab = statusbar.ActionBar(m) + + prep_msg = ab.prep_message("Error: Fits into statusbar") + assert prep_msg == [(None, "Error: Fits into statusbar"), ("warn", "")] + + prep_msg = ab.prep_message("Error: Doesn't fit into statusbar"*2) + assert prep_msg == [(None, "Error: Doesn't fit into statu..."), + ("warn", "(more in eventlog)")] + + prep_msg = ab.prep_message("Error: Two lines.\nFirst fits") + assert prep_msg == [(None, "Error: Two lines."), + ("warn", "(more in eventlog)")] + + prep_msg = ab.prep_message("Error: Two lines"*4 + "\nFirst doensn't fit") + assert prep_msg == [(None, "Error: Two linesError: Two li..."), + ("warn", "(more in eventlog)")] |