Exemple #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)
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)
Exemple #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
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
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
Exemple #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
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)
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)
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
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
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)
Exemple #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)
Exemple #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)
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
Exemple #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
def test_message_parse_strict(bs, message):
    bs = bytes(bytearray(bs))
    protocol = BinaryProtocol()

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

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