aboutsummaryrefslogtreecommitdiffstats
path: root/test/mitmproxy/test_console_pathedit.py
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2016-02-15 16:34:22 +0100
committerMaximilian Hils <git@maximilianhils.com>2016-02-15 16:34:22 +0100
commitd7158f975e671b78f0a064dd873cfa7805667528 (patch)
tree9b40f263c4f613a0dc49f5d8628c371164afd546 /test/mitmproxy/test_console_pathedit.py
parent5fe473fb431699c71aa74bb715c2cb5b0500f044 (diff)
downloadmitmproxy-d7158f975e671b78f0a064dd873cfa7805667528.tar.gz
mitmproxy-d7158f975e671b78f0a064dd873cfa7805667528.tar.bz2
mitmproxy-d7158f975e671b78f0a064dd873cfa7805667528.zip
move tests into shared folder
Diffstat (limited to 'test/mitmproxy/test_console_pathedit.py')
-rw-r--r--test/mitmproxy/test_console_pathedit.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/test/mitmproxy/test_console_pathedit.py b/test/mitmproxy/test_console_pathedit.py
new file mode 100644
index 00000000..940351f5
--- /dev/null
+++ b/test/mitmproxy/test_console_pathedit.py
@@ -0,0 +1,49 @@
+import os
+from os.path import normpath
+from libmproxy.console import pathedit
+
+from . import tutils
+
+
+class TestPathCompleter:
+
+ def test_lookup_construction(self):
+ c = pathedit._PathCompleter()
+
+ cd = tutils.test_data.path("completion")
+ ca = os.path.join(cd, "a")
+ assert c.complete(ca).endswith(normpath("/completion/aaa"))
+ assert c.complete(ca).endswith(normpath("/completion/aab"))
+ c.reset()
+ ca = os.path.join(cd, "aaa")
+ assert c.complete(ca).endswith(normpath("/completion/aaa"))
+ assert c.complete(ca).endswith(normpath("/completion/aaa"))
+ c.reset()
+ assert c.complete(cd).endswith(normpath("/completion/aaa"))
+
+ def test_completion(self):
+ c = pathedit._PathCompleter(True)
+ c.reset()
+ c.lookup = [
+ ("a", "x/a"),
+ ("aa", "x/aa"),
+ ]
+ assert c.complete("a") == "a"
+ assert c.final == "x/a"
+ assert c.complete("a") == "aa"
+ assert c.complete("a") == "a"
+
+ c = pathedit._PathCompleter(True)
+ r = c.complete("l")
+ assert c.final.endswith(r)
+
+ c.reset()
+ assert c.complete("/nonexistent") == "/nonexistent"
+ assert c.final == "/nonexistent"
+ c.reset()
+ assert c.complete("~") != "~"
+
+ c.reset()
+ s = "thisisatotallynonexistantpathforsure"
+ assert c.complete(s) == s
+ assert c.final == s