mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-24 00:31:33 +00:00
2f670bac99
We currently test with unparallelized builds, because there are apparently some race conditions in the test suite, which I can't trigger locally but happen on travis. Squashed commit of the following: commit 7dceb6dd3a1bdbc39688258bc4dff6eee685a33b Author: Maximilian Hils <git@maximilianhils.com> Date: Mon Sep 21 23:00:24 2015 +0200 disable parallelized tests commit fc0c3f12ee9259162e83026851362925d93b69f2 Author: Maximilian Hils <git@maximilianhils.com> Date: Mon Sep 21 22:49:19 2015 +0200 fix tests commit baba3ca5ef49bdbd7aad14f1bf0626738fa3d21c Author: Maximilian Hils <git@maximilianhils.com> Date: Mon Sep 21 22:28:20 2015 +0200 fix tests, use py.test
60 lines
1.8 KiB
Python
60 lines
1.8 KiB
Python
from libpathod import pathoc_cmdline as cmdline
|
|
import tutils
|
|
import cStringIO
|
|
import mock
|
|
|
|
|
|
@mock.patch("argparse.ArgumentParser.error")
|
|
def test_pathoc(perror):
|
|
assert cmdline.args_pathoc(["pathoc", "foo.com", "get:/"])
|
|
s = cStringIO.StringIO()
|
|
with tutils.raises(SystemExit):
|
|
cmdline.args_pathoc(["pathoc", "--show-uas"], s, s)
|
|
|
|
a = cmdline.args_pathoc(["pathoc", "foo.com:8888", "get:/"])
|
|
assert a.port == 8888
|
|
|
|
a = cmdline.args_pathoc(["pathoc", "foo.com:xxx", "get:/"])
|
|
assert perror.called
|
|
perror.reset_mock()
|
|
|
|
a = cmdline.args_pathoc(["pathoc", "-I", "10, 20", "foo.com:8888", "get:/"])
|
|
assert a.ignorecodes == [10, 20]
|
|
|
|
a = cmdline.args_pathoc(["pathoc", "-I", "xx, 20", "foo.com:8888", "get:/"])
|
|
assert perror.called
|
|
perror.reset_mock()
|
|
|
|
a = cmdline.args_pathoc(["pathoc", "-c", "foo:10", "foo.com:8888", "get:/"])
|
|
assert a.connect_to == ["foo", 10]
|
|
|
|
a = cmdline.args_pathoc(["pathoc", "foo.com", "get:/", "--http2"])
|
|
assert a.use_http2 == True
|
|
assert a.ssl == True
|
|
|
|
a = cmdline.args_pathoc(["pathoc", "foo.com", "get:/", "--http2-skip-connection-preface"])
|
|
assert a.use_http2 == True
|
|
assert a.ssl == True
|
|
assert a.http2_skip_connection_preface == True
|
|
|
|
a = cmdline.args_pathoc(["pathoc", "-c", "foo", "foo.com:8888", "get:/"])
|
|
assert perror.called
|
|
perror.reset_mock()
|
|
|
|
a = cmdline.args_pathoc(
|
|
["pathoc", "-c", "foo:bar", "foo.com:8888", "get:/"])
|
|
assert perror.called
|
|
perror.reset_mock()
|
|
|
|
a = cmdline.args_pathoc(
|
|
[
|
|
"pathoc",
|
|
"foo.com:8888",
|
|
tutils.test_data.path("data/request")
|
|
]
|
|
)
|
|
assert len(list(a.requests)) == 1
|
|
|
|
with tutils.raises(SystemExit):
|
|
cmdline.args_pathoc(["pathoc", "foo.com", "invalid"], s, s)
|