Fix the test for websocket connection.

This commit is contained in:
Matthew Shao 2017-07-05 18:57:19 +08:00
parent 7516f706b4
commit 37fea267c1

View File

@ -275,12 +275,32 @@ class TestApp(tornado.testing.AsyncHTTPTestCase):
ws_client = yield websocket.websocket_connect(ws_url) ws_client = yield websocket.websocket_connect(ws_url)
self.master.options.anticomp = True self.master.options.anticomp = True
response = yield ws_client.read_message() r1 = yield ws_client.read_message()
assert _json.loads(response) == { 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", "resource": "settings",
"cmd": "update", "cmd": "update",
"data": {"anticomp": True}, "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() ws_client.close()
# trigger on_close by opening a second connection. # trigger on_close by opening a second connection.