diff options
author | Maximilian Hils <git@maximilianhils.com> | 2016-06-20 20:36:31 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-20 20:36:31 -0700 |
commit | 44abb4caea145a39b441d6af0d79fb07b672af1d (patch) | |
tree | 72d1bed290cf76a21e3c8398c4cd738c2244a509 | |
parent | 7ef0e37c74698a5f8f41b6f268b9e5f71db0ba2f (diff) | |
parent | 6aeba9777a105da85cf5d8c69defc521aff67212 (diff) | |
download | mitmproxy-44abb4caea145a39b441d6af0d79fb07b672af1d.tar.gz mitmproxy-44abb4caea145a39b441d6af0d79fb07b672af1d.tar.bz2 mitmproxy-44abb4caea145a39b441d6af0d79fb07b672af1d.zip |
Merge pull request #1276 from dufferzafar/console-pathedit
mitmproxy.console tests - PathEdit
-rw-r--r-- | test/mitmproxy/completion/bbb/Readme.md | 2 | ||||
-rw-r--r-- | test/mitmproxy/console/test_pathedit.py | 24 |
2 files changed, 26 insertions, 0 deletions
diff --git a/test/mitmproxy/completion/bbb/Readme.md b/test/mitmproxy/completion/bbb/Readme.md new file mode 100644 index 00000000..ac534722 --- /dev/null +++ b/test/mitmproxy/completion/bbb/Readme.md @@ -0,0 +1,2 @@ + +This empty directory has been added so that we can hit [this line](https://codecov.io/gh/mitmproxy/mitmproxy/src/ba13fda10d3065a0c8dfd95d55680675b3bf08c2/mitmproxy/console/pathedit.py#L43) while testing pathedit completion. 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 |