Add tests for set_focus

This commit is contained in:
Nikhil Soni 2017-03-29 01:51:44 +05:30
parent 70a0f87570
commit 442999c75c
1 changed files with 16 additions and 0 deletions

View File

@ -1,4 +1,5 @@
from unittest import mock
import urwid
import mitmproxy.tools.console.flowlist as flowlist
from mitmproxy.tools import console
@ -19,3 +20,18 @@ class TestFlowlist:
with mock.patch('mitmproxy.tools.console.signals.status_message.send') as mock_thing:
x.new_request("nonexistent url", "GET")
mock_thing.assert_called_once_with(message="Invalid URL: No hostname given")
def test_logbuffer_set_focus(self):
m = self.mkmaster()
b = flowlist.LogBufferBox(m)
e = urwid.Text("Log message")
m.logbuffer.append(e)
m.logbuffer.append(e)
assert len(m.logbuffer) == 2
b.set_focus(0)
assert m.logbuffer.focus == 0
b.set_focus(1)
assert m.logbuffer.focus == 1
b.set_focus(2)
assert m.logbuffer.focus == 1