예제 #1
0
파일: test_exec.py 프로젝트: wsmoyer/shuup
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")
예제 #2
0
파일: test_exec.py 프로젝트: wsmoyer/shuup
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)
예제 #3
0
def test_non_empty():
    ie = NonEmpty({"v": {"variable": "v"}})
    assert ie.test(Context.from_variables(v=True))
    assert not ie.test(Context.from_variables(v=""))
    assert not ie.test(Context.from_variables(v=0))
예제 #4
0
def test_non_empty():
    ie = NonEmpty({"v": {"variable": "v"}})
    assert ie.test(Context.from_variables(v=True))
    assert not ie.test(Context.from_variables(v=""))
    assert not ie.test(Context.from_variables(v=0))