Exemplo n.º 1
0
def test_pipeline_previous_follows_initial_path():
    pipeline = Pipeline()
    pipeline.add_stage('Stage 1', Stage1)
    pipeline.add_stage('Stage 2', Stage2)
    pipeline.add_stage('Stage 2b', Stage2b)
    pipeline.add_stage('Stage 3', DummyStage)

    pipeline.define_graph({
        'Stage 1': ('Stage 2', 'Stage 2b'),
        'Stage 2': 'Stage 3',
        'Stage 2b': 'Stage 3'
    })

    pipeline.init()

    assert pipeline._route == ['Stage 1']

    pipeline.next_selector.value = 'Stage 2b'
    pipeline._next()

    assert pipeline._route == ['Stage 1', 'Stage 2b']

    pipeline._next()

    assert pipeline._route == ['Stage 1', 'Stage 2b', 'Stage 3']

    pipeline._previous()

    assert pipeline._stage == 'Stage 2b'
    assert pipeline._route == ['Stage 1', 'Stage 2b']
Exemplo n.º 2
0
def test_pipeline_network_diagram_states():
    pipeline = Pipeline(ready_parameter='ready', auto_advance=True)
    pipeline.add_stage('Stage 1', Stage1)
    pipeline.add_stage('Stage 2', Stage2)
    pipeline.add_stage('Stage 2b', Stage2b)

    pipeline.define_graph({'Stage 1': ('Stage 2', 'Stage 2b')})

    pipeline.init()

    [s1, s2, s2b] = pipeline.network.object.nodes['State']

    assert s1 == 'active'
    assert s2 == 'inactive'
    assert s2b == 'next'

    pipeline._next()

    [s1, s2, s2b] = pipeline.network.object.nodes['State']

    assert s1 == 'inactive'
    assert s2 == 'inactive'
    assert s2b == 'active'

    pipeline._previous()

    [s1, s2, s2b] = pipeline.network.object.nodes['State']

    assert s1 == 'active'
    assert s2 == 'inactive'
    assert s2b == 'next'
Exemplo n.º 3
0
def test_pipeline_auto_advance_respected():
    pipeline = Pipeline(ready_parameter='ready', auto_advance=True)
    pipeline.add_stage('Stage 1', Stage1)
    pipeline.add_stage('Stage 2', Stage2)

    pipeline.init()

    assert pipeline.next_button.disabled

    pipeline._state.ready = True

    assert isinstance(pipeline._state, Stage2)
Exemplo n.º 4
0
def test_pipeline_ready_respected():
    pipeline = Pipeline(ready_parameter='ready')
    pipeline.add_stage('Stage 1', Stage1)
    pipeline.add_stage('Stage 2', Stage2)

    pipeline.init()

    assert pipeline.next_button.disabled

    pipeline._state.ready = True

    assert not pipeline.next_button.disabled
Exemplo n.º 5
0
def test_pipeline_define_next_parameter_respected():
    pipeline = Pipeline()
    pipeline.add_stage('Stage 2', Stage2)
    pipeline.add_stage('Stage 2b', Stage2b)
    pipeline.add_stage('Stage 1',
                       Stage1(next='Stage 2b'),
                       next_parameter='next')

    pipeline.define_graph({'Stage 1': ('Stage 2', 'Stage 2b')})

    pipeline.init()

    assert pipeline.next_selector.value == 'Stage 2b'

    pipeline._state.next = 'Stage 2'

    assert pipeline.next_selector.value == 'Stage 2'
Exemplo n.º 6
0
def test_pipeline_error_condition():
    pipeline = Pipeline()
    stage2b = Stage2b(root='error')
    pipeline.add_stage('Stage 2', Stage2)
    pipeline.add_stage('Stage 2b', stage2b)
    pipeline.add_stage('Stage 1', Stage1)

    pipeline.define_graph({'Stage 1': ('Stage 2', 'Stage 2b')})

    pipeline.init()

    pipeline.next_selector.value = 'Stage 2b'
    pipeline._next()

    assert isinstance(pipeline.error[0], Button)

    stage2b.root = 2

    pipeline._next()

    assert len(pipeline.error) == 0
Exemplo n.º 7
0
def test_pipeline_define_graph():
    pipeline = Pipeline()
    pipeline.add_stage('Stage 2', Stage2)
    pipeline.add_stage('Stage 2b', Stage2b)
    pipeline.add_stage('Stage 1', Stage1)

    pipeline.define_graph({'Stage 1': ('Stage 2', 'Stage 2b')})

    pipeline.init()

    assert pipeline._stage == 'Stage 1'

    assert isinstance(pipeline.buttons, Row)
    (pselect, pbutton), (nselect, nbutton) = pipeline.buttons
    assert isinstance(pselect, Select)
    assert pselect.disabled
    assert isinstance(pbutton, Button)
    assert pbutton.disabled

    assert isinstance(nselect, Select)
    assert not nselect.disabled
    assert nselect.options == ['Stage 2', 'Stage 2b']
    assert nselect.value == 'Stage 2'
    assert isinstance(nbutton, Button)
    assert not nbutton.disabled

    pipeline._next()

    assert isinstance(pipeline._state, Stage2)

    pipeline._previous()

    nselect.value = 'Stage 2b'

    pipeline._next()

    assert isinstance(pipeline._state, Stage2b)