예제 #1
0
def test_unknown_type_id(typ, bs):
    protocol = BinaryProtocol()

    with pytest.raises(ThriftProtocolError) as exc_info:
        protocol.deserialize_value(typ, bytes(bytearray(bs)))

    assert 'Unknown TType' in str(exc_info)
예제 #2
0
def test_unknown_type_id(typ, bs):
    protocol = BinaryProtocol()

    with pytest.raises(ThriftProtocolError) as exc_info:
        protocol.deserialize_value(typ, bytes(bytearray(bs)))

    assert 'Unknown TType' in str(exc_info)
예제 #3
0
def test_message_round_trip(bs, message):
    bs = bytes(bytearray(bs))
    protocol = BinaryProtocol()

    result = protocol.deserialize_message(bs)
    assert message == result

    result = protocol.serialize_message(message)
    assert bs == result
예제 #4
0
def test_message_round_trip(bs, message):
    bs = bytes(bytearray(bs))
    protocol = BinaryProtocol()

    result = protocol.deserialize_message(bs)
    assert message == result

    result = protocol.serialize_message(message)
    assert bs == result
예제 #5
0
def test_reader_and_writer_noorder(spec, value):
    """Test serialization and deserialization for types
    that have no guaranteed order."""
    protocol = BinaryProtocol()

    buffer = WriteBuffer()
    spec.write_to(protocol.writer(buffer), value)
    result = spec.read_from(protocol.reader(ReadBuffer(buffer.value)))

    assert result == value
예제 #6
0
def test_reader_and_writer_noorder(spec, value):
    """Test serialization and deserialization for types
    that have no guaranteed order."""
    protocol = BinaryProtocol()

    buffer = WriteBuffer()
    spec.write_to(protocol.writer(buffer), value)
    result = spec.read_from(protocol.reader(ReadBuffer(buffer.value)))

    assert result == value
예제 #7
0
def test_input_too_short(typ, bs):
    """Test that EndOfInputError is raised when not enough bytes are
    available."""

    protocol = BinaryProtocol()

    with pytest.raises(EndOfInputError) as exc_info:
        protocol.deserialize_value(typ, bytes(bytearray(bs)))

    assert 'bytes but got' in str(exc_info)
예제 #8
0
def test_input_too_short(typ, bs):
    """Test that EndOfInputError is raised when not enough bytes are
    available."""

    protocol = BinaryProtocol()

    with pytest.raises(EndOfInputError) as exc_info:
        protocol.deserialize_value(typ, bytes(bytearray(bs)))

    assert 'bytes but got' in str(exc_info)
예제 #9
0
def test_reader_and_writer(typ, bs, value):
    """Test serialization and deserialization of all samples."""
    bs = bytes(bytearray(bs))

    protocol = BinaryProtocol()

    result = protocol.deserialize_value(typ, bs)
    assert value == result

    result = protocol.serialize_value(value)
    assert bs == result
예제 #10
0
def test_reader_and_writer(typ, bs, value):
    """Test serialization and deserialization of all samples."""
    bs = bytes(bytearray(bs))

    protocol = BinaryProtocol()

    result = protocol.deserialize_value(typ, bs)
    assert value == result

    result = protocol.serialize_value(value)
    assert bs == result
예제 #11
0
def test_input_too_short(typ, spec, bs):
    """Test that EndOfInputError is raised when not enough bytes are
    available."""

    protocol = BinaryProtocol()

    with pytest.raises(EndOfInputError) as exc_info:
        s = bytes(bytearray(bs))
        protocol.deserialize_value(typ, s)

        reader = protocol.reader(ReadBuffer(s))
        spec.read_from(reader)

    assert 'bytes but got' in str(exc_info)
예제 #12
0
def test_message_invalid_version(bs):
    bs = bytes(bytearray(bs))

    with pytest.raises(ThriftProtocolError) as exc_info:
        BinaryProtocol().deserialize_message(bs)

    assert 'Unsupported version "42"' in str(exc_info)
예제 #13
0
def test_input_too_short(typ, spec, bs):
    """Test that EndOfInputError is raised when not enough bytes are
    available."""

    protocol = BinaryProtocol()

    with pytest.raises(EndOfInputError) as exc_info:
        s = bytes(bytearray(bs))
        protocol.deserialize_value(typ, s)

    assert 'bytes but got' in str(exc_info)

    with pytest.raises(EndOfInputError) as exc_info:
        reader = protocol.reader(ReadBuffer(s))
        spec.read_from(reader)

    assert 'bytes but got' in str(exc_info)
예제 #14
0
def test_reader_and_writer(typ, bs, spec, value):
    """Test serialization and deserialization of all samples."""
    bs = bytes(bytearray(bs))

    protocol = BinaryProtocol()

    result = protocol.deserialize_value(typ, bs)
    assert value == result

    result = protocol.serialize_value(value)
    assert bs == result

    buffer = ReadBuffer(bs)
    deserialized = spec.read_from(protocol.reader(buffer))
    buffer = WriteBuffer()
    spec.write_to(protocol.writer(buffer), deserialized)

    assert bs == buffer.value
예제 #15
0
def test_reader_and_writer(typ, bs, spec, value):
    """Test serialization and deserialization of all samples."""
    bs = bytes(bytearray(bs))

    protocol = BinaryProtocol()

    result = protocol.deserialize_value(typ, bs)
    assert value == result

    result = protocol.serialize_value(value)
    assert bs == result

    buffer = ReadBuffer(bs)
    deserialized = spec.read_from(protocol.reader(buffer))
    buffer = WriteBuffer()
    spec.write_to(protocol.writer(buffer), deserialized)

    assert bs == buffer.value
예제 #16
0
def test_message_parse_strict(bs, message):
    bs = bytes(bytearray(bs))
    protocol = BinaryProtocol()

    result = protocol.deserialize_message(bs)
    assert message == result
예제 #17
0
def test_message_parse_strict(bs, message):
    bs = bytes(bytearray(bs))
    protocol = BinaryProtocol()

    result = protocol.deserialize_message(bs)
    assert message == result