diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/mitmproxy/tools/console/test_statusbar.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/mitmproxy/tools/console/test_statusbar.py b/test/mitmproxy/tools/console/test_statusbar.py index db8a63a7..108f238e 100644 --- a/test/mitmproxy/tools/console/test_statusbar.py +++ b/test/mitmproxy/tools/console/test_statusbar.py @@ -1,3 +1,5 @@ +import pytest + from mitmproxy import options from mitmproxy.tools.console import statusbar, master @@ -31,3 +33,29 @@ def test_statusbar(monkeypatch): bar = statusbar.StatusBar(m) # this already causes a redraw assert bar.ib._w + + +@pytest.mark.parametrize("message,ready_message", [ + ("", [(None, ""), ("warn", "")]), + (("info", "Line fits into statusbar"), [("info", "Line fits into statusbar"), + ("warn", "")]), + ("Line doesn't fit into statusbar", [(None, "Line doesn'\u2026"), + ("warn", "(more in eventlog)")]), + (("alert", "Two lines.\nFirst fits"), [("alert", "Two lines."), + ("warn", "(more in eventlog)")]), + ("Two long lines\nFirst doesn't fit", [(None, "Two long li\u2026"), + ("warn", "(more in eventlog)")]) +]) +def test_shorten_message(message, ready_message): + o = options.Options() + m = master.ConsoleMaster(o) + ab = statusbar.ActionBar(m) + assert ab.shorten_message(message, max_width=30) == ready_message + + +def test_shorten_message_narrow(): + o = options.Options() + m = master.ConsoleMaster(o) + ab = statusbar.ActionBar(m) + shorten_msg = ab.shorten_message("error", max_width=4) + assert shorten_msg == [(None, "\u2026"), ("warn", "(more in eventlog)")] |