diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/mitmproxy/test_optmanager.py | 5 | ||||
-rw-r--r-- | test/mitmproxy/tools/web/test_app.py | 10 | ||||
-rw-r--r-- | test/mitmproxy/utils/test_typecheck.py | 8 |
3 files changed, 23 insertions, 0 deletions
diff --git a/test/mitmproxy/test_optmanager.py b/test/mitmproxy/test_optmanager.py index cadc5d76..0c400683 100644 --- a/test/mitmproxy/test_optmanager.py +++ b/test/mitmproxy/test_optmanager.py @@ -338,6 +338,11 @@ def test_dump_defaults(): assert optmanager.dump_defaults(o) +def test_dump_dicts(): + o = options.Options() + assert optmanager.dump_dicts(o) + + class TTypes(optmanager.OptManager): def __init__(self): super().__init__() diff --git a/test/mitmproxy/tools/web/test_app.py b/test/mitmproxy/tools/web/test_app.py index 5427b995..e6d563e7 100644 --- a/test/mitmproxy/tools/web/test_app.py +++ b/test/mitmproxy/tools/web/test_app.py @@ -253,6 +253,16 @@ class TestApp(tornado.testing.AsyncHTTPTestCase): assert self.put_json("/settings", {"anticache": True}).code == 200 assert self.put_json("/settings", {"wtf": True}).code == 400 + def test_options(self): + j = json(self.fetch("/options")) + assert type(j) == list + assert type(j[0]) == dict + + def test_option_update(self): + assert self.put_json("/options", {"anticache": True}).code == 200 + assert self.put_json("/options", {"wtf": True}).code == 400 + assert self.put_json("/options", {"anticache": "foo"}).code == 400 + def test_err(self): with mock.patch("mitmproxy.tools.web.app.IndexHandler.get") as f: f.side_effect = RuntimeError diff --git a/test/mitmproxy/utils/test_typecheck.py b/test/mitmproxy/utils/test_typecheck.py index fe33070e..66b1884e 100644 --- a/test/mitmproxy/utils/test_typecheck.py +++ b/test/mitmproxy/utils/test_typecheck.py @@ -111,3 +111,11 @@ def test_check_command_type(): m.__str__ = lambda self: "typing.Union" m.__union_params__ = (int,) assert not typecheck.check_command_type([22], m) + + +def test_typesec_to_str(): + assert(typecheck.typespec_to_str(str)) == "str" + assert(typecheck.typespec_to_str(typing.Sequence[str])) == "sequence of str" + assert(typecheck.typespec_to_str(typing.Optional[str])) == "optional str" + with pytest.raises(NotImplementedError): + typecheck.typespec_to_str(dict) |