Skip to content

Commit

Permalink
remove whitespace in json serialization
Browse files Browse the repository at this point in the history
Signed-off-by: Pierre Tardy <pierre.tardy@intel.com>
  • Loading branch information
Pierre Tardy committed Mar 20, 2015
1 parent 7a5b7e2 commit 824d75e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions master/buildbot/test/unit/test_www_ws.py
Expand Up @@ -31,28 +31,28 @@ def setUp(self):

def test_ping(self):
self.proto.onMessage(json.dumps(dict(cmd="ping", _id=1)), False)
self.proto.sendMessage.assert_called_with('{"msg": "pong", "code": 200, "_id": 1}')
self.proto.sendMessage.assert_called_with('{"msg":"pong","code":200,"_id":1}')

def test_bad_cmd(self):
self.proto.onMessage(json.dumps(dict(cmd="poing", _id=1)), False)
self.proto.sendMessage.assert_called_with(
'{"_id": 1, "code": 404, "error": "no such command \'poing\'"}')
'{"_id":1,"code":404,"error":"no such command \'poing\'"}')

def test_no_cmd(self):
self.proto.onMessage(json.dumps(dict(_id=1)), False)
self.proto.sendMessage.assert_called_with(
'{"_id": null, "code": 400, "error": "no \'cmd\' in websocket frame"}')
'{"_id":null,"code":400,"error":"no \'cmd\' in websocket frame"}')

def test_no_id(self):
self.proto.onMessage(json.dumps(dict(cmd="ping")), False)
self.proto.sendMessage.assert_called_with(
'{"_id": null, "code": 400, "error": "no \'_id\' in websocket frame"}')
'{"_id":null,"code":400,"error":"no \'_id\' in websocket frame"}')

def test_startConsuming(self):
self.proto.onMessage(json.dumps(dict(cmd="startConsuming", path="builds/*/*", _id=1)), False)
self.proto.sendMessage.assert_called_with(
'{"msg": "OK", "code": 200, "_id": 1}')
'{"msg":"OK","code":200,"_id":1}')
self.master.mq.verifyMessages = False
self.master.mq.callConsumer(("builds", "1", "new"), {"buildid": 1})
self.proto.sendMessage.assert_called_with(
'{"m": {"buildid": 1}, "k": "builds/1/new"}')
'{"k":"builds/1/new","m":{"buildid":1}}')
2 changes: 1 addition & 1 deletion master/buildbot/www/ws.py
Expand Up @@ -30,7 +30,7 @@ def __init__(self, master):
self.qrefs = {}

def sendJsonMessage(self, **msg):
self.sendMessage(json.dumps(msg, default=toJson).encode('utf8'))
self.sendMessage(json.dumps(msg, default=toJson, separators=(',', ':')).encode('utf8'))

def onMessage(self, frame, isBinary):
log.msg("FRAME %s" % frame)
Expand Down

0 comments on commit 824d75e

Please sign in to comment.