mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-27 10:26:23 +00:00
1ffc273c94
- Move more stuff that belongs in netlib.human - Move some stuff to near the only use - Zap mitmproxy.utils.timestamp(). I see the rationale, but we used it interchangeably with time.time() throughout the project. Since time.time() dominates in the codebase and timestamp() is such low utility, away it goes.
90 lines
1.6 KiB
Python
90 lines
1.6 KiB
Python
from pathod import pathod_cmdline as cmdline
|
|
import tutils
|
|
import mock
|
|
|
|
|
|
def test_parse_anchor_spec():
|
|
assert cmdline.parse_anchor_spec("foo=200") == ("foo", "200")
|
|
assert cmdline.parse_anchor_spec("foo") is None
|
|
|
|
|
|
@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()
|
|
|
|
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()
|