diff options
author | Shadab Zafar <dufferzafar0@gmail.com> | 2016-06-20 00:50:41 +0530 |
---|---|---|
committer | Shadab Zafar <dufferzafar0@gmail.com> | 2016-06-20 00:50:41 +0530 |
commit | ba13fda10d3065a0c8dfd95d55680675b3bf08c2 (patch) | |
tree | 07403be4120873c6b52947183e8c41c2cecfca51 /test | |
parent | c4c9527fa0ff2cc9299082321845739261f41f8f (diff) | |
download | mitmproxy-ba13fda10d3065a0c8dfd95d55680675b3bf08c2.tar.gz mitmproxy-ba13fda10d3065a0c8dfd95d55680675b3bf08c2.tar.bz2 mitmproxy-ba13fda10d3065a0c8dfd95d55680675b3bf08c2.zip |
Add tests for PathEdit
Diffstat (limited to 'test')
-rw-r--r-- | test/mitmproxy/console/test_pathedit.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/mitmproxy/console/test_pathedit.py b/test/mitmproxy/console/test_pathedit.py index 107a48ac..ff6ef846 100644 --- a/test/mitmproxy/console/test_pathedit.py +++ b/test/mitmproxy/console/test_pathedit.py @@ -2,6 +2,8 @@ import os from os.path import normpath from mitmproxy.console import pathedit +from mock import patch + from .. import tutils @@ -47,3 +49,25 @@ class TestPathCompleter: s = "thisisatotallynonexistantpathforsure" assert c.complete(s) == s assert c.final == s + + +class TestPathEdit(): + + def test_keypress(self): + + pe = pathedit.PathEdit() + + with patch('urwid.widget.Edit.get_edit_text') as get_text, \ + patch('urwid.widget.Edit.set_edit_text') as set_text: + + cd = tutils.test_data.path("completion") + get_text.return_value = os.path.join(cd, "a") + + # Pressing tab should set completed path + pe.keypress((1,), "tab") + set_text_called_with = set_text.call_args[0][0] + assert set_text_called_with.endswith(normpath("/completion/aaa")) + + # Pressing any other key should reset + pe.keypress((1,), "a") + assert pe.lookup is None |