aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/test_console_help.py10
-rw-r--r--test/test_console_palettes.py11
-rw-r--r--test/test_dump.py7
-rwxr-xr-xtest/tools/testpatt9
4 files changed, 33 insertions, 4 deletions
diff --git a/test/test_console_help.py b/test/test_console_help.py
index 6e1f9fad..a410bd2e 100644
--- a/test/test_console_help.py
+++ b/test/test_console_help.py
@@ -5,7 +5,14 @@ if os.name == "nt":
import libmproxy.console.help as help
+class DummyLoop:
+ def __init__(self):
+ self.widget = None
+
class DummyMaster:
+ def __init__(self):
+ self.loop = DummyLoop()
+
def make_view(self):
pass
@@ -16,7 +23,8 @@ class TestHelp:
assert h.helptext()
def test_keypress(self):
- h = help.HelpView(DummyMaster(), "foo", [1, 2, 3])
+ master = DummyMaster()
+ h = help.HelpView(master, "foo", [1, 2, 3])
assert not h.keypress((0, 0), "q")
assert not h.keypress((0, 0), "?")
assert h.keypress((0, 0), "o") == "o"
diff --git a/test/test_console_palettes.py b/test/test_console_palettes.py
new file mode 100644
index 00000000..3f8e280a
--- /dev/null
+++ b/test/test_console_palettes.py
@@ -0,0 +1,11 @@
+import os
+from nose.plugins.skip import SkipTest
+if os.name == "nt":
+ raise SkipTest("Skipped on Windows.")
+import libmproxy.console.palettes as palettes
+
+
+class TestPalette:
+ def test_helptext(self):
+ for i in palettes.palettes.values():
+ assert i.palette()
diff --git a/test/test_dump.py b/test/test_dump.py
index 11a024e3..48eeb244 100644
--- a/test/test_dump.py
+++ b/test/test_dump.py
@@ -131,14 +131,16 @@ class TestDumpMaster:
assert len(m.apps.apps) == 1
def test_replacements(self):
+ cs = StringIO()
o = dump.Options(replacements=[(".*", "content", "foo")])
- m = dump.DumpMaster(None, o)
+ m = dump.DumpMaster(None, o, outfile=cs)
f = self._cycle(m, "content")
assert f.request.content == "foo"
def test_setheader(self):
+ cs = StringIO()
o = dump.Options(setheaders=[(".*", "one", "two")])
- m = dump.DumpMaster(None, o)
+ m = dump.DumpMaster(None, o, outfile=cs)
f = self._cycle(m, "content")
assert f.request.headers["one"] == ["two"]
@@ -195,4 +197,3 @@ class TestDumpMaster:
def test_stickyauth(self):
self._dummy_cycle(1, None, "", stickyauth = ".*")
-
diff --git a/test/tools/testpatt b/test/tools/testpatt
new file mode 100755
index 00000000..f6d1169b
--- /dev/null
+++ b/test/tools/testpatt
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+# Generate a test pattern with pathoc
+PATHOD=http://localhost:9999
+pathoc localhost:8080 "get:'$PATHOD/p/200:p0,1:b@200b'"
+pathoc localhost:8080 "get:'$PATHOD/p/300:p0,1:b@200b'"
+pathoc localhost:8080 "get:'$PATHOD/p/400:p0,1:b@200b'"
+pathoc localhost:8080 "get:'$PATHOD/p/500:p0,1:b@200b'"
+pathoc localhost:8080 "get:'$PATHOD/p/600:p0,1:b@200b'"