aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_pathod_cmdline.py
diff options
context:
space:
mode:
authorThomas Kriechbaumer <thomas@kriechbaumer.name>2015-06-08 16:03:33 +0200
committerThomas Kriechbaumer <thomas@kriechbaumer.name>2015-06-15 15:50:44 +0200
commit18a4456397d0b4b1275ac2c8ab393d041176e949 (patch)
tree538f54756665f50143e75615b88575646d2ed204 /test/test_pathod_cmdline.py
parent9ececa637d69ee3991fbc82f3cd64ae781a86f5d (diff)
downloadmitmproxy-18a4456397d0b4b1275ac2c8ab393d041176e949.tar.gz
mitmproxy-18a4456397d0b4b1275ac2c8ab393d041176e949.tar.bz2
mitmproxy-18a4456397d0b4b1275ac2c8ab393d041176e949.zip
refactor cmdline tests
Diffstat (limited to 'test/test_pathod_cmdline.py')
-rw-r--r--test/test_pathod_cmdline.py104
1 files changed, 104 insertions, 0 deletions
diff --git a/test/test_pathod_cmdline.py b/test/test_pathod_cmdline.py
new file mode 100644
index 00000000..590bb56b
--- /dev/null
+++ b/test/test_pathod_cmdline.py
@@ -0,0 +1,104 @@
+from libpathod import pathod_cmdline as cmdline
+import tutils
+import cStringIO
+import mock
+
+
+@mock.patch("argparse.ArgumentParser.error")
+def test_pathod(perror):
+ assert cmdline.args_pathod(["pathod"])
+
+ a = cmdline.args_pathod(
+ [
+ "pathod",
+ "--cert",
+ tutils.test_data.path("data/testkey.pem")
+ ]
+ )
+ assert a.ssl_certs
+
+ a = cmdline.args_pathod(
+ [
+ "pathod",
+ "--cert",
+ "nonexistent"
+ ]
+ )
+ assert perror.called
+ perror.reset_mock()
+
+ a = cmdline.args_pathod(
+ [
+ "pathod",
+ "-a",
+ "foo=200"
+ ]
+ )
+ assert a.anchors
+
+ a = cmdline.args_pathod(
+ [
+ "pathod",
+ "-a",
+ "foo=" + tutils.test_data.path("data/response")
+ ]
+ )
+ assert a.anchors
+
+ a = cmdline.args_pathod(
+ [
+ "pathod",
+ "-a",
+ "?=200"
+ ]
+ )
+ assert perror.called
+ perror.reset_mock()
+
+ a = cmdline.args_pathod(
+ [
+ "pathod",
+ "-a",
+ "foo"
+ ]
+ )
+ assert perror.called
+ perror.reset_mock()
+
+ s = cStringIO.StringIO()
+ tutils.raises(
+ SystemExit,
+ cmdline.args_pathod,
+ ["pathod", "-a", "foo=."],
+ s,
+ s
+ )
+
+ a = cmdline.args_pathod(
+ [
+ "pathod",
+ "--limit-size",
+ "200k"
+ ]
+ )
+ assert a.sizelimit
+
+ a = cmdline.args_pathod(
+ [
+ "pathod",
+ "--limit-size",
+ "q"
+ ]
+ )
+ assert perror.called
+ perror.reset_mock()
+
+ a = cmdline.args_pathod(
+ [
+ "pathod",
+ "-c",
+ "?"
+ ]
+ )
+ assert perror.called
+ perror.reset_mock()