From 03bb0a09b95d1942a62435545d867b0888de75fa Mon Sep 17 00:00:00 2001 From: Matthew Shao Date: Mon, 12 Jun 2017 20:27:21 +0800 Subject: Add tests for dump_dicts in optmanager.py. --- test/mitmproxy/test_optmanager.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'test') diff --git a/test/mitmproxy/test_optmanager.py b/test/mitmproxy/test_optmanager.py index 04ec7ded..37fe0e3a 100644 --- a/test/mitmproxy/test_optmanager.py +++ b/test/mitmproxy/test_optmanager.py @@ -334,6 +334,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__() -- cgit v1.2.3 From 2c0f6c202321a9d332dbe0181d319a3be4fd2614 Mon Sep 17 00:00:00 2001 From: Matthew Shao Date: Tue, 13 Jun 2017 23:03:07 +0800 Subject: Minor Update and add test. --- test/mitmproxy/tools/web/test_app.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'test') diff --git a/test/mitmproxy/tools/web/test_app.py b/test/mitmproxy/tools/web/test_app.py index 5427b995..d47b1af0 100644 --- a/test/mitmproxy/tools/web/test_app.py +++ b/test/mitmproxy/tools/web/test_app.py @@ -253,6 +253,11 @@ 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_err(self): with mock.patch("mitmproxy.tools.web.app.IndexHandler.get") as f: f.side_effect = RuntimeError -- cgit v1.2.3 From 9687d676012379f5875331423fbbbe33fcd63434 Mon Sep 17 00:00:00 2001 From: Matthew Shao Date: Wed, 14 Jun 2017 07:44:00 +0800 Subject: Add test for typespec_to_str. --- test/mitmproxy/utils/test_typecheck.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test') diff --git a/test/mitmproxy/utils/test_typecheck.py b/test/mitmproxy/utils/test_typecheck.py index fe33070e..8e4198da 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" + assert(typecheck.typespec_to_str(typing.Optional[str])) == "Union" + with pytest.raises(NotImplementedError): + typecheck.typespec_to_str(dict) -- cgit v1.2.3 From c7ce7f84e6283fa08e87ee5ee35fd6053a2ab615 Mon Sep 17 00:00:00 2001 From: Matthew Shao Date: Fri, 23 Jun 2017 10:45:04 +0800 Subject: Add test for POST /options API of mitmweb. --- test/mitmproxy/tools/web/test_app.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'test') diff --git a/test/mitmproxy/tools/web/test_app.py b/test/mitmproxy/tools/web/test_app.py index d47b1af0..401f9fe6 100644 --- a/test/mitmproxy/tools/web/test_app.py +++ b/test/mitmproxy/tools/web/test_app.py @@ -258,6 +258,10 @@ class TestApp(tornado.testing.AsyncHTTPTestCase): 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 + def test_err(self): with mock.patch("mitmproxy.tools.web.app.IndexHandler.get") as f: f.side_effect = RuntimeError -- cgit v1.2.3 From 18633262201b33fb0c36381fbc65febf21313eb7 Mon Sep 17 00:00:00 2001 From: Matthew Shao Date: Sat, 24 Jun 2017 10:18:00 +0800 Subject: Minor Update for /options API of mitmweb. --- test/mitmproxy/tools/web/test_app.py | 1 + test/mitmproxy/utils/test_typecheck.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/mitmproxy/tools/web/test_app.py b/test/mitmproxy/tools/web/test_app.py index 401f9fe6..e6d563e7 100644 --- a/test/mitmproxy/tools/web/test_app.py +++ b/test/mitmproxy/tools/web/test_app.py @@ -261,6 +261,7 @@ class TestApp(tornado.testing.AsyncHTTPTestCase): 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: diff --git a/test/mitmproxy/utils/test_typecheck.py b/test/mitmproxy/utils/test_typecheck.py index 8e4198da..66b1884e 100644 --- a/test/mitmproxy/utils/test_typecheck.py +++ b/test/mitmproxy/utils/test_typecheck.py @@ -115,7 +115,7 @@ def test_check_command_type(): def test_typesec_to_str(): assert(typecheck.typespec_to_str(str)) == "str" - assert(typecheck.typespec_to_str(typing.Sequence[str])) == "Sequence" - assert(typecheck.typespec_to_str(typing.Optional[str])) == "Union" + 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) -- cgit v1.2.3