예제 #1
0
def test_next_reads_only_one_user_and_then_thoughts(user_info, thought):
    parser = ProtobufSampleParser()
    b = BytesIO(b"".join(
        _build_message_buffer(x)
        for x in (user_info, thought, user_info, thought)))
    out = parser.next(b)
    with pytest.raises(DecodeError):
        out = parser.next(b)
예제 #2
0
def test_next_reads_all_thoughts(user_info, thought):
    """
    next should only return the thoughts, not the user.
    :param parser:
    :return:
    """
    parser = ProtobufSampleParser()
    b = BytesIO(b"".join(
        _build_message_buffer(x) for x in (user_info, thought, thought)))
    out = parser.next(b)
    assert parser.user == user_info
    while out:
        assert out.snapshot == thought
        out = parser.next(b)
예제 #3
0
def test_next_reads_user_first(user_info):
    parser = ProtobufSampleParser()
    b = _build_message_buffer(user_info)
    assert parser.next(BytesIO(b)) is None
    assert parser.user == user_info