Ejemplo n.º 1
0
def test_automatic_pipeline_clocked():
    """Exercise AutomaticPipeline's clock functionality."""
    print('Testing Automatic Pipeline with factory make_pipeline_delayed:')
    pipeline = make_pipeline_delayed(AutomaticPipeline)
    print(pipeline)

    assert pipeline.update_clock(0) is None
    write_bottom_chunked_buffers(pipeline.bottom)
    assert pipeline.update_clock(0) == 1.0
    assert not pipeline.top.has_receive()
    assert pipeline.update_clock(0.5) == 1.0
    assert not pipeline.top.has_receive()
    assert pipeline.update_clock(0.99) == 1.0
    assert not pipeline.top.has_receive()
    assert pipeline.update_clock(1.0) is None
    assert_bottom_events(pipeline.top)

    print('Resetting clock...')
    assert pipeline.update_clock(0) is None
    write_top_events(pipeline.top)
    assert pipeline.update_clock(0) == 1.0
    assert pipeline.update_clock(0.5) == 1.0
    assert not pipeline.bottom.to_write()
    assert pipeline.update_clock(0.75) == 1.0
    assert not pipeline.bottom.to_write()
    assert pipeline.update_clock(1.5) is None
    result = pipeline.bottom.to_write()
    assert result == HIGHER_CHUNKED_STREAM
Ejemplo n.º 2
0
def test_automatic_pipeline_loopback():
    """Exercise ManualPipeline's interface."""
    print('Testing Automatic Pipeline with factory make_pipeline_loopback:')
    automatic_pipeline = make_pipeline_loopback(AutomaticPipeline)
    print(automatic_pipeline)

    write_bottom_chunked_buffers(automatic_pipeline.bottom)
    result = automatic_pipeline.bottom.to_write()
    print('Pipeline bottom wrote to stream: {}'.format(result))
    assert result == LOWER_CHUNKED_STREAM
Ejemplo n.º 3
0
def test_manual_pipeline_loopback():
    """Exercise ManualPipeline's interface."""
    print('Testing Manual Pipeline with factory make_pipeline_loopback:')
    manual_pipeline = make_pipeline_loopback(ManualPipeline)
    print(manual_pipeline)

    write_bottom_chunked_buffers(manual_pipeline.bottom)
    assert manual_pipeline.sync() is None
    result = manual_pipeline.bottom.to_write()
    print('Pipeline bottom wrote to stream: {}'.format(result))
    assert result == LOWER_CHUNKED_STREAM
Ejemplo n.º 4
0
def test_automatic_pipeline(pipeline_factory):
    """Exercise AutomaticPipeline's interface."""
    print('Testing Automatic Pipeline with factory {}:'.format(
        pipeline_factory.__name__))
    automatic_pipeline = pipeline_factory(AutomaticPipeline)
    print(automatic_pipeline)

    # Read/write on links
    write_bottom_chunked_buffers(automatic_pipeline.bottom)
    assert_bottom_events(automatic_pipeline.top)
    write_top_events(automatic_pipeline.top)
    result = automatic_pipeline.bottom.to_write()
    print('Pipeline bottom wrote to stream: {}'.format(result))
    assert result == HIGHER_CHUNKED_STREAM

    # Read/write on pipeline
    write_bottom_chunked_buffers(automatic_pipeline)
    assert_bottom_events(automatic_pipeline)
    write_top_events(automatic_pipeline)
    result = automatic_pipeline.to_write()
    print('Pipeline bottom wrote to stream: {}'.format(result))
    assert result == HIGHER_CHUNKED_STREAM
Ejemplo n.º 5
0
def test_manual_pipeline(pipeline_factory):
    """Exercise ManualPipeline's interface."""
    print('Testing Manual Pipeline with factory {}:'.format(
        pipeline_factory.__name__))
    pipeline = pipeline_factory(ManualPipeline)
    print(pipeline)

    # Read/write on links with directional sync
    write_bottom_chunked_buffers(pipeline.bottom)
    assert pipeline.sync_up() is None
    assert_bottom_events(pipeline.top)
    write_top_events(pipeline.top)
    assert pipeline.sync_down() is None
    result = pipeline.bottom.to_write()
    print('Pipeline bottom wrote to stream: {}'.format(result))
    assert result == HIGHER_CHUNKED_STREAM

    # Read/write on links with bidirectional sync
    write_bottom_chunked_buffers(pipeline.bottom)
    assert pipeline.sync() is None
    assert_bottom_events(pipeline.top)
    write_top_events(pipeline.top)
    assert pipeline.sync() is None
    result = pipeline.bottom.to_write()
    print('Pipeline bottom wrote to stream: {}'.format(result))
    assert result == HIGHER_CHUNKED_STREAM

    # Read/write on pipe with bidirectionl sync
    write_bottom_chunked_buffers(pipeline)
    assert pipeline.sync() is None
    assert_bottom_events(pipeline)
    write_top_events(pipeline)
    assert pipeline.sync() is None
    result = pipeline.to_write()
    print('Pipeline bottom wrote to stream: {}'.format(result))
    assert result == HIGHER_CHUNKED_STREAM