class RequestHandlerProtocolTestCase(unittest.TestCase): def setUp(self): super(RequestHandlerProtocolTestCase, self).setUp() self.protocol = RequestHandlerProtocol() def test_encode_message(self): message = json.dumps({'key': 'value'}).encode('utf-8') self.assertEqual(self.protocol._encode_message(message), message) self.assertEqual( self.protocol._encode_message(message, isBinary=True), b64encode(message) ) def test_decode_message(self): data = {'url': '/api'} message = json.dumps(data).encode('utf-8') request = self.protocol._decode_message(message) self.assertEqual({'url': request.url}, data) def test_decode_message_binary(self): data = {'url': '/api'} message = json.dumps(data).encode('utf-8') message = b64encode(message) request = self.protocol._decode_message(message, isBinary=True) self.assertEqual({'url': request.url}, data)
class RequestHandlerProtocolTestCase(unittest.TestCase): def setUp(self): super(RequestHandlerProtocolTestCase, self).setUp() self.protocol = RequestHandlerProtocol() def test_encode_message(self): message = json.dumps({"key": "value"}).encode("utf-8") self.assertEqual(self.protocol._encode_message(message), message) self.assertEqual(self.protocol._encode_message(message, isBinary=True), b64encode(message)) def test_decode_message(self): data = {"url": "/api"} message = json.dumps(data).encode("utf-8") request = self.protocol._decode_message(message) self.assertEqual({"url": request.url}, data) def test_decode_message_binary(self): data = {"url": "/api"} message = json.dumps(data).encode("utf-8") message = b64encode(message) request = self.protocol._decode_message(message, isBinary=True) self.assertEqual({"url": request.url}, data)
def setUp(self): super(RequestHandlerProtocolTestCase, self).setUp() self.protocol = RequestHandlerProtocol()