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' }) 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']
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')}) [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'
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')}) 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)