Exemple #1
0
def test_lookup():
    assert Matcher.lookup("username", {"username": "******"}, {}) == "kernel"
    assert Matcher.lookup("msg", {"username": "******", "msg": "hello"}, {}) == "hello"

    assert Matcher.lookup("data", {"msg": "something"}, {}) == {}
    assert Matcher.lookup("data", {"msg": "something"}, {"hello": "world"}) == {"hello": "world"}

    assert Matcher.lookup("data.key", {"msg": "something"}, {"key": "value"}) == "value"
    assert Matcher.lookup("data.hello", {"msg": "something"}, {"hello": "world"}) == "world"

    with pytest.raises(KeyError):
        Matcher.lookup("msg", {}, {})
    with pytest.raises(KeyError):
        Matcher.lookup("msg", {}, {"msg": "value"})
    with pytest.raises(KeyError):
        Matcher.lookup("msg", {"username": "******"}, {})
    with pytest.raises(KeyError):
        Matcher.lookup("data.username", {"username": "******"}, {})