def test_nested_or_conditions():
    or_sat = top.Or(
        [NeverSatisfied(),
         top.Or([top.Immediate(), NeverSatisfied()])])
    or_unsat = top.Or(
        [NeverSatisfied(),
         top.Or([NeverSatisfied(), NeverSatisfied()])])

    assert or_sat.satisfied() is True
    assert or_unsat.satisfied() is False
Exemplo n.º 2
0
def branching_procedure_suite_no_options():
    close_action = top.StateChangeAction('c1', 'closed')
    open_action = top.StateChangeAction('c1', 'open')
    halfway_open_action = top.StateChangeAction('c1', 'halfway_open')

    s1 = top.ProcedureStep('s1', close_action,
                           [(NeverSatisfied(), top.Transition('p1', 's2')),
                            (NeverSatisfied(), top.Transition('p2', 's3'))],
                           'PRIMARY')
    s2 = top.ProcedureStep('s2', halfway_open_action, [], 'PRIMARY')
    s3 = top.ProcedureStep('s3', open_action, [], 'PRIMARY')

    proc_1 = top.Procedure('p1', [s1, s2, s3])
    proc_2 = top.Procedure('p2', [s1, s2, s3])

    return top.ProcedureSuite([proc_1, proc_2], 'p1')
def test_or_equality():
    or_1 = top.Or([top.Immediate(), top.Immediate()])
    or_2 = top.Or([top.Immediate(), top.Immediate()])
    or_3 = top.Or([NeverSatisfied(), top.Immediate()])

    assert or_1 == or_2
    assert or_1 != or_3

    assert or_1 != 10
    assert or_1 is not None
def test_and_equality():
    and_1 = top.And([top.Immediate(), top.Immediate()])
    and_2 = top.And([top.Immediate(), top.Immediate()])
    and_3 = top.And([NeverSatisfied(), top.Immediate()])

    assert and_1 == and_2
    assert and_1 != and_3

    assert and_1 != 10
    assert and_1 is not None
def test_nested_and_conditions():
    and_sat = top.And(
        [top.Immediate(),
         top.And([top.Immediate(), top.Immediate()])])
    and_unsat = top.And(
        [top.Immediate(),
         top.And([NeverSatisfied(), top.Immediate()])])

    assert and_sat.satisfied() is True
    assert and_unsat.satisfied() is False
Exemplo n.º 6
0
def test_transitions_respects_procedure_identifier():
    plumb_eng = one_component_engine()

    action = top.MiscAction('Do nothing')

    s1 = top.ProcedureStep(
        's1', action, [(NeverSatisfied(), top.Transition('p1', 'same_name')),
                       (top.Immediate(), top.Transition('p2', 'same_name'))],
        'PRIMARY')
    same_name_1 = top.ProcedureStep('same_name', action, [], 'PRIMARY')
    same_name_2 = top.ProcedureStep('same_name', action, [], 'PRIMARY')

    proc_1 = top.Procedure('p1', [s1, same_name_1])
    proc_2 = top.Procedure('p2', [same_name_2])
    proc_suite = top.ProcedureSuite([proc_1, proc_2], 'p1')

    proc_eng = top.ProceduresEngine(plumb_eng, proc_suite)
    proc_eng.execute_current()

    assert proc_eng.current_procedure_id == 'p1'
    assert proc_eng.current_step.step_id == 's1'
    proc_eng.next_step()
    assert proc_eng.current_procedure_id == 'p2'
    assert proc_eng.current_step.step_id == 'same_name'
def test_and_or_not_equal():
    and_cond = top.And([NeverSatisfied(), top.Immediate()])
    or_cond = top.Or([NeverSatisfied(), top.Immediate()])

    assert and_cond != or_cond
def test_or_one_condition():
    or_sat = top.Or([top.Immediate()])
    or_unsat = top.Or([NeverSatisfied()])

    assert or_sat.satisfied() is True
    assert or_unsat.satisfied() is False