Example #1
0
def test_none_condop():
    step = Step(cond_op=StepConditionOperator.NONE, conditions=[
        NonEmpty({"v": {"variable": "a"}}),
        NonEmpty({"v": {"variable": "b"}}),
    ], actions=[SetDebugFlag({})])
    context = Context.from_variables(a=False, b=False)
    step.execute(context)
    assert context.get("debug")
Example #2
0
def test_none_condop():
    step = Step(cond_op=StepConditionOperator.NONE, conditions=[
        NonEmpty({"v": {"variable": "a"}}),
        NonEmpty({"v": {"variable": "b"}}),
    ], actions=[SetDebugFlag({})])
    context = Context.from_variables(a=False, b=False)
    step.execute(context)
    assert context.get("debug")
Example #3
0
def test_render_template():
    step = Step(
        conditions=(),
        actions=[Action.unserialize(action) for action in TEST_STEP_ACTIONS],
    )
    assert step

    execution_context = Context(variables={
        "customer_phone": "0594036495",
        "language": "fi",
        "customer_email": "*****@*****.**"
    })

    step.execute(context=execution_context)
Example #4
0
def test_render_template():
    step = Step(
        conditions=(),
        actions=[Action.unserialize(action) for action in TEST_STEP_ACTIONS],
    )
    assert step

    execution_context = Context(variables={
        "customer_phone": "0594036495",
        "language": "fi",
        "customer_email": "*****@*****.**"
    })

    step.execute(context=execution_context)
Example #5
0
def test_condops(cond_op):
    step = Step(cond_op=cond_op, conditions=[
        NonEmpty({"v": {"variable": "a"}}),
        NonEmpty({"v": {"variable": "b"}}),
    ], actions=[SetDebugFlag({})])
    context = Context.from_variables(a=True, b=False)
    step.execute(context)
    if cond_op == StepConditionOperator.ALL:
        assert not context.get("debug")
    elif cond_op == StepConditionOperator.ANY:
        assert context.get("debug")
    elif cond_op == StepConditionOperator.NONE:
        assert not context.get("debug")
    else:
        raise ValueError("Unexpected condop %r" % cond_op)
Example #6
0
def test_condops(cond_op):
    step = Step(cond_op=cond_op, conditions=[
        NonEmpty({"v": {"variable": "a"}}),
        NonEmpty({"v": {"variable": "b"}}),
    ], actions=[SetDebugFlag({})])
    context = Context.from_variables(a=True, b=False)
    step.execute(context)
    if cond_op == StepConditionOperator.ALL:
        assert not context.get("debug")
    elif cond_op == StepConditionOperator.ANY:
        assert context.get("debug")
    elif cond_op == StepConditionOperator.NONE:
        assert not context.get("debug")
    else:
        raise ValueError("Unexpected condop %r" % cond_op)
Example #7
0
def test_conditionless_step_executes():
    step = Step(actions=[SetDebugFlag({})])
    context = Context()
    step.execute(context)
    assert context.get("debug")
Example #8
0
def test_conditionless_step_executes():
    step = Step(actions=[SetDebugFlag({})])
    context = Context()
    step.execute(context)
    assert context.get("debug")