def test_pack_string(): b = BytesIO() proto.write_val(b, TType.STRING, "hello world!") assert_equal("00 00 00 0c 68 65 6c 6c 6f 20 77 6f 72 6c 64 21", hexlify(b.getvalue())) b = BytesIO() proto.write_val(b, TType.STRING, u("你好世界")) assert_equal("00 00 00 0c e4 bd a0 e5 a5 bd e4 b8 96 e7 95 8c", hexlify(b.getvalue()))
def test_pack_string(): b = BytesIO() proto.write_val(b, TType.STRING, "hello world!") assert "00 00 00 0c 68 65 6c 6c 6f 20 77 6f 72 6c 64 21" == \ hexlify(b.getvalue()) b = BytesIO() proto.write_val(b, TType.STRING, u("你好世界")) assert "00 00 00 0c e4 bd a0 e5 a5 bd e4 b8 96 e7 95 8c" == \ hexlify(b.getvalue())
def read(self, _): """ Mock response, we don't care about results. We never actually read them. But we don't want client to wait for server to reply. """ buffer = BytesIO() seq_id = 0 # Sequence id is never compared to message. write_message_begin(buffer, 'Log_result', TMessageType.REPLY, seq_id) response = scribe_thrift.Scribe.Log_result( success=scribe_thrift.ResultCode.OK) write_val(buffer, TType.STRUCT, response) out = buffer.getvalue() # Framed message, starts with length of message. return struct.pack('!i', len(out)) + out
def test_pack_double(): b = BytesIO() proto.write_val(b, TType.DOUBLE, 1234567890.1234567890) assert_equal("41 d2 65 80 b4 87 e6 b7", hexlify(b.getvalue()))
def test_pack_i64(): b = BytesIO() proto.write_val(b, TType.I64, 1234567890123456789) assert_equal("11 22 10 f4 7d e9 81 15", hexlify(b.getvalue()))
def test_pack_i32(): b = BytesIO() proto.write_val(b, TType.I32, 1234567890) assert_equal("49 96 02 d2", hexlify(b.getvalue()))
def test_pack_i16(): b = BytesIO() proto.write_val(b, TType.I16, 12345) assert_equal("30 39", hexlify(b.getvalue()))
def test_pack_i8(): b = BytesIO() proto.write_val(b, TType.I08, 123) assert_equal("7b", hexlify(b.getvalue()))
def test_pack_double(): b = BytesIO() proto.write_val(b, TType.DOUBLE, 1234567890.1234567890) assert "41 d2 65 80 b4 87 e6 b7" == hexlify(b.getvalue())
def test_pack_i64(): b = BytesIO() proto.write_val(b, TType.I64, 1234567890123456789) assert "11 22 10 f4 7d e9 81 15" == hexlify(b.getvalue())
def test_pack_i32(): b = BytesIO() proto.write_val(b, TType.I32, 1234567890) assert "49 96 02 d2" == hexlify(b.getvalue())
def test_pack_i16(): b = BytesIO() proto.write_val(b, TType.I16, 12345) assert "30 39" == hexlify(b.getvalue())
def test_pack_i8(): b = BytesIO() proto.write_val(b, TType.I08, 123) assert "7b" == hexlify(b.getvalue())
def write_struct(self, obj): write_val(self.trans, TType.STRUCT, obj)