diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2015-04-17 18:00:46 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2015-04-17 18:00:46 +1200 |
commit | 3061bdd0c214d9a25e055ee8f4bc1a744221762a (patch) | |
tree | 22bf151076a2efc0957b5443d6cd532c0cbe04aa /test/test_cmdline.py | |
parent | f8e95db6b0a3978327e68fa859b3e98537640e6e (diff) | |
download | mitmproxy-3061bdd0c214d9a25e055ee8f4bc1a744221762a.tar.gz mitmproxy-3061bdd0c214d9a25e055ee8f4bc1a744221762a.tar.bz2 mitmproxy-3061bdd0c214d9a25e055ee8f4bc1a744221762a.zip |
Unit tests: cmdline.pathod
Diffstat (limited to 'test/test_cmdline.py')
-rw-r--r-- | test/test_cmdline.py | 89 |
1 files changed, 88 insertions, 1 deletions
diff --git a/test/test_cmdline.py b/test/test_cmdline.py index d1c79d77..c51b6cf0 100644 --- a/test/test_cmdline.py +++ b/test/test_cmdline.py @@ -4,9 +4,96 @@ import cStringIO import mock -def test_pathod(): +@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() + @mock.patch("argparse.ArgumentParser.error") def test_pathoc(perror): |