mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-22 07:08:10 +00:00
[web] Update tests.
This commit is contained in:
parent
8c3e988a8c
commit
5c45a90ce9
@ -285,6 +285,10 @@ def test_saving(tmpdir):
|
||||
optmanager.load_paths(o, dst)
|
||||
assert o.three == "foo"
|
||||
|
||||
o2 = TD2()
|
||||
o2.three = "foo"
|
||||
assert(optmanager.save(o2, None, defaults=False)) == "three: foo\n"
|
||||
|
||||
with open(dst, 'a') as f:
|
||||
f.write("foobar: '123'")
|
||||
assert optmanager.load_paths(o, dst) == {"foobar": "123"}
|
||||
|
@ -263,6 +263,18 @@ class TestApp(tornado.testing.AsyncHTTPTestCase):
|
||||
assert self.put_json("/options", {"wtf": True}).code == 400
|
||||
assert self.put_json("/options", {"anticache": "foo"}).code == 400
|
||||
|
||||
def test_option_dump(self):
|
||||
resp = self.fetch("/options/dump")
|
||||
assert b"http2: false" in resp.body
|
||||
|
||||
assert self.fetch("/options/dump", method="POST", body=b"http2: true").code == 200
|
||||
j = json(self.fetch("/options"))
|
||||
assert j["http2"]["value"]
|
||||
|
||||
resp = self.fetch("/options/dump", method="POST", body=b"wtf: true")
|
||||
assert resp.code == 400
|
||||
assert resp.body == b"'Unknown options: wtf'"
|
||||
|
||||
def test_err(self):
|
||||
with mock.patch("mitmproxy.tools.web.app.IndexHandler.get") as f:
|
||||
f.side_effect = RuntimeError
|
||||
@ -279,7 +291,6 @@ class TestApp(tornado.testing.AsyncHTTPTestCase):
|
||||
r2 = yield ws_client.read_message()
|
||||
j1 = _json.loads(r1)
|
||||
j2 = _json.loads(r2)
|
||||
print(j1)
|
||||
response = dict()
|
||||
response[j1['resource']] = j1
|
||||
response[j2['resource']] = j2
|
||||
|
@ -246,7 +246,34 @@ exports[`Modal Component should render correctly 2`] = `
|
||||
</div>
|
||||
<div
|
||||
className="modal-footer"
|
||||
/>
|
||||
>
|
||||
<button
|
||||
className="btn btn-default"
|
||||
onClick={[Function]}
|
||||
type="button"
|
||||
>
|
||||
<i
|
||||
className="fa fa-download"
|
||||
/>
|
||||
Download
|
||||
</button>
|
||||
<a
|
||||
className="btn btn-primary"
|
||||
href="#"
|
||||
onClick={[Function]}
|
||||
title={undefined}
|
||||
>
|
||||
<i
|
||||
className="fa fa-fw fa-upload"
|
||||
/>
|
||||
Load
|
||||
<input
|
||||
className="hidden"
|
||||
onChange={[Function]}
|
||||
type="file"
|
||||
/>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user