Пример #1
0
def test_build_fails_with_message_writer_and_serializer(
    dummy_message_writer: DummyMessageWriter, string_message_serializer: MessageSerializer
):
    builder = PipelineBuilder()
    builder.with_message_writer(dummy_message_writer)
    builder.with_input_message_serializer(string_message_serializer)

    with pytest.raises(EsqueIOInvalidPipelineBuilderState):
        builder.build()
Пример #2
0
def test_build_fails_with_message_writer_and_handler(
    dummy_message_writer: DummyMessageWriter, dummy_handler: DummyHandler
):
    builder = PipelineBuilder()
    builder.with_message_writer(dummy_message_writer)
    builder.with_input_handler(dummy_handler)

    with pytest.raises(EsqueIOInvalidPipelineBuilderState):
        builder.build()
Пример #3
0
def test_create_pipeline_with_message_writer(
    dummy_message_writer, binary_messages: List[BinaryMessage], string_messages: List[Message]
):
    builder = PipelineBuilder()
    builder.with_message_writer(dummy_message_writer)
    pipeline = builder.build()

    pipeline.write_many_messages(string_messages)

    assert dummy_message_writer.get_written_messages() == binary_messages
Пример #4
0
def prepared_builder(
    dummy_message_reader: DummyMessageReader,
    dummy_message_writer: DummyMessageWriter,
    binary_messages: List[BinaryMessage],
) -> PipelineBuilder:
    builder = PipelineBuilder()
    builder.with_message_reader(dummy_message_reader)
    builder.with_message_writer(dummy_message_writer)
    dummy_message_reader.set_messages(binary_messages)

    return builder
Пример #5
0
def test_build_fails_with_message_writer_and_uri(
    dummy_message_writer: DummyMessageWriter,
    string_message_serializer: MessageSerializer,
    dummy_handler: DummyHandler,
    output_uri: str,
):
    builder = PipelineBuilder()
    builder.with_message_writer(dummy_message_writer)
    builder.with_output_from_uri(output_uri)

    with pytest.raises(EsqueIOInvalidPipelineBuilderState):
        builder.build()