def testJsonString(self): codec = jsonCodec() message = codec.decode(DummyPahoMessage("bar")) try: assert_true(isinstance(message.data, unicode)) except NameError as e: # Python 3 assert_true(isinstance(message.data, str))
def testInvalidJson(self): codec = jsonCodec() message = codec.decode(NonJsonDummyPahoMessage('{sss,eee}'))
def testJsonInt(self): codec = jsonCodec() message = codec.decode(DummyPahoMessage(1)) assert_true(isinstance(message.data, int))
def testJsonBoolean(self): codec = jsonCodec() message = codec.decode(DummyPahoMessage(False)) assert_true(isinstance(message.data, bool))
def testJsonObject(self): codec = jsonCodec() message = codec.decode(DummyPahoMessage({"foo": "bar"})) assert_true(isinstance(message.data, dict)) assert_equals(message.data["foo"], "bar")