From 37fea267c1d171fb661736b96db62943e7b49791 Mon Sep 17 00:00:00 2001 From: Matthew Shao Date: Wed, 5 Jul 2017 18:57:19 +0800 Subject: [PATCH] Fix the test for websocket connection. --- test/mitmproxy/tools/web/test_app.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/test/mitmproxy/tools/web/test_app.py b/test/mitmproxy/tools/web/test_app.py index 044b45951..bb439b340 100644 --- a/test/mitmproxy/tools/web/test_app.py +++ b/test/mitmproxy/tools/web/test_app.py @@ -275,12 +275,32 @@ class TestApp(tornado.testing.AsyncHTTPTestCase): ws_client = yield websocket.websocket_connect(ws_url) self.master.options.anticomp = True - response = yield ws_client.read_message() - assert _json.loads(response) == { + r1 = yield ws_client.read_message() + 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 + assert response['settings'] == { "resource": "settings", "cmd": "update", "data": {"anticomp": True}, } + assert response['options'] == { + "resource": "options", + "cmd": "update", + "data": { + "anticomp": { + "value": True, + "choices": None, + "default": False, + "help": "Try to convince servers to send us un-compressed data.", + "type": "bool", + } + } + } ws_client.close() # trigger on_close by opening a second connection.