예제 #1
0
def test_Env_dyn_jpath():
    env=reqman.Env( {"orig":dict(x=42)} )
    assert reqman.jpath(env,"orig.x") == 42

    env.save("data", dict(x=42))
    assert reqman.jpath(env,"data.x") == 42
    assert reqman.jpath(env,"data.size") == 1
예제 #2
0
def test_jpath():
    assert reqman.jpath({'v': 42}, "v") == 42
    assert reqman.jpath({'v': 42}, "v2") is reqman.NotFound

    env = reqman.Env(
        dict(toto=dict(v1=100, v2=None), tata=dict(l=["a", "b", "c"])))
    assert reqman.jpath(env, "titi") is reqman.NotFound
    assert reqman.jpath(env, "titi.size") is reqman.NotFound
    assert reqman.jpath(env, "titi.0") is reqman.NotFound

    assert reqman.jpath(env, "toto.v1") == 100
    assert reqman.jpath(env, "toto.v2") == None
    assert reqman.jpath(env, "toto.v3") is reqman.NotFound
    assert reqman.jpath(env, "toto.size") == 2

    assert reqman.jpath(env, "tata.l") == ["a", "b", "c"]
    assert reqman.jpath(env, "tata.l.1") == "b"
    assert reqman.jpath(env, "tata.l.1.size") == 1
    assert reqman.jpath(env, "tata.l.size") == 3
예제 #3
0
def test_jpath_python():
    env = dict(fct="return dict(a=dict(b=42))")
    assert reqman.jpath(env, "fct.size") == 1
    assert reqman.jpath(env, "fct.a.b") == 42