Exemple #1
0
def test_name_node():
    node = Node()
    step_node = node.add(Step('foo'))
    variables = {}
    assert node.resolve('foo', variables) is step_node
    assert not variables

    assert node.resolve('bar', variables) is None
    assert not variables
Exemple #2
0
def test_name_node():
    node = Node()
    step_node = node.add(Step('foo'))
    variables = {}
    assert node.resolve('foo', variables) is step_node
    assert not variables

    assert node.resolve('bar', variables) is None
    assert not variables
Exemple #3
0
def test_name_node():
    node = Node()
    step_node = node.add(Step("foo"))
    variables = {}
    assert node.resolve("foo", variables) is step_node
    assert not variables

    assert node.resolve("bar", variables) is None
    assert not variables
Exemple #4
0
def test_variable_node():
    node = Node()

    step_node = node.add(Step("{x}"))
    variables = {}
    assert node.resolve("foo", variables) is step_node
    assert variables == {"x": "foo"}

    variables = {}
    assert node.resolve("bar", variables) is step_node
    assert variables == {"x": "bar"}
Exemple #5
0
def test_variable_node():
    node = Node()

    step_node = node.add(Step('{x}'))
    variables = {}
    assert node.resolve('foo', variables) is step_node
    assert variables == {'x': 'foo'}

    variables = {}
    assert node.resolve('bar', variables) is step_node
    assert variables == {'x': 'bar'}
Exemple #6
0
def test_variable_node():
    node = Node()

    step_node = node.add(Step('{x}'))
    variables = {}
    assert node.resolve('foo', variables) is step_node
    assert variables == {'x': 'foo'}

    variables = {}
    assert node.resolve('bar', variables) is step_node
    assert variables == {'x': 'bar'}
Exemple #7
0
def test_variable_node_optional_colon():
    node = Node()
    x_node = node.add(Step('{x}'))
    xy_node = node.add(Step('{x}:{y}'))

    variables = {}
    assert node.resolve('a', variables) is x_node
    assert variables == {'x': 'a'}

    variables = {}
    assert node.resolve('a:b', variables) is xy_node
    assert variables == {'x': 'a', 'y': 'b'}
Exemple #8
0
def test_variable_node_specific_first():
    node = Node()
    x_node = node.add(Step('{x}'))

    prefix_node = node.add(Step('prefix{x}'))

    variables = {}
    assert node.resolve('what', variables) is x_node
    assert variables == {'x': 'what'}

    variables = {}
    assert node.resolve('prefixwhat', variables) is prefix_node
    assert variables == {'x': 'what'}
Exemple #9
0
def test_mixed_node():
    node = Node()
    step_node = node.add(Step('prefix{x}postfix'))

    variables = {}
    assert node.resolve('prefixfoopostfix', variables) is step_node
    assert variables == {'x': 'foo'}

    variables = {}
    assert node.resolve('prefixbarpostfix', variables) is step_node
    assert variables == {'x': 'bar'}

    variables = {}
    assert node.resolve('prefixwhat', variables) is None
    assert variables == {}
Exemple #10
0
def test_variable_node_more_specific_first():
    node = Node()
    xy_node = node.add(Step('x{x}y'))
    xay_node = node.add(Step('xa{x}y'))
    ay_node = node.add(Step('a{x}y'))
    assert node.get('xwhaty') == (xy_node, {'x': 'what'})
    assert node.get('xawhaty') == (xay_node, {'x': 'what'})
    assert node.get('awhaty') == (ay_node, {'x': 'what'})
Exemple #11
0
def test_variable_node_more_specific_first():
    node = Node()
    xy_node = node.add(Step('x{x}y'))
    xay_node = node.add(Step('xa{x}y'))
    ay_node = node.add(Step('a{x}y'))
    assert node.get('xwhaty') == (xy_node, {'x': 'what'})
    assert node.get('xawhaty') == (xay_node, {'x': 'what'})
    assert node.get('awhaty') == (ay_node, {'x': 'what'})
Exemple #12
0
def test_variable_node_more_specific_first():
    node = Node()
    xy_node = node.add(Step("x{x}y"))
    xay_node = node.add(Step("xa{x}y"))
    ay_node = node.add(Step("a{x}y"))
    assert node.get("xwhaty") == (xy_node, {"x": "what"})
    assert node.get("xawhaty") == (xay_node, {"x": "what"})
    assert node.get("awhaty") == (ay_node, {"x": "what"})
Exemple #13
0
def test_variable_node_more_specific_first():
    node = Node()
    xy_node = node.add(Step("x{x}y"))
    xay_node = node.add(Step("xa{x}y"))
    ay_node = node.add(Step("a{x}y"))

    variables = {}
    assert node.resolve("xwhaty", variables) is xy_node
    assert variables == {"x": "what"}

    variables = {}
    assert node.resolve("xawhaty", variables) is xay_node
    assert variables == {"x": "what"}

    variables = {}
    assert node.resolve("awhaty", variables) is ay_node
    assert variables == {"x": "what"}
Exemple #14
0
def test_variable_node_more_specific_first():
    node = Node()
    xy_node = node.add(Step('x{x}y'))
    xay_node = node.add(Step('xa{x}y'))
    ay_node = node.add(Step('a{x}y'))

    variables = {}
    assert node.resolve('xwhaty', variables) is xy_node
    assert variables == {'x': 'what'}

    variables = {}
    assert node.resolve('xawhaty', variables) is xay_node
    assert variables == {'x': 'what'}

    variables = {}
    assert node.resolve('awhaty', variables) is ay_node
    assert variables == {'x': 'what'}
Exemple #15
0
def test_variable_node_optional_colon():
    node = Node()
    x_node = node.add(Step('{x}'))
    xy_node = node.add(Step('{x}:{y}'))

    variables = {}
    assert node.resolve('a', variables) is x_node
    assert variables == {'x': 'a'}

    variables = {}
    assert node.resolve('a:b', variables) is xy_node
    assert variables == {'x': 'a', 'y': 'b'}
Exemple #16
0
def test_variable_node_optional_colon():
    node = Node()
    x_node = node.add(Step("{x}"))
    xy_node = node.add(Step("{x}:{y}"))

    variables = {}
    assert node.resolve("a", variables) is x_node
    assert variables == {"x": "a"}

    variables = {}
    assert node.resolve("a:b", variables) is xy_node
    assert variables == {"x": "a", "y": "b"}
Exemple #17
0
def test_variable_node_specific_first():
    node = Node()
    x_node = node.add(Step("{x}"))

    prefix_node = node.add(Step("prefix{x}"))

    variables = {}
    assert node.resolve("what", variables) is x_node
    assert variables == {"x": "what"}

    variables = {}
    assert node.resolve("prefixwhat", variables) is prefix_node
    assert variables == {"x": "what"}
Exemple #18
0
def test_variable_node_specific_first():
    node = Node()
    x_node = node.add(Step('{x}'))

    prefix_node = node.add(Step('prefix{x}'))

    variables = {}
    assert node.resolve('what', variables) is x_node
    assert variables == {'x': 'what'}

    variables = {}
    assert node.resolve('prefixwhat', variables) is prefix_node
    assert variables == {'x': 'what'}
Exemple #19
0
def test_variable_node_more_specific_first():
    node = Node()
    xy_node = node.add(Step('x{x}y'))
    xay_node = node.add(Step('xa{x}y'))
    ay_node = node.add(Step('a{x}y'))

    variables = {}
    assert node.resolve('xwhaty', variables) is xy_node
    assert variables == {'x': 'what'}

    variables = {}
    assert node.resolve('xawhaty', variables) is xay_node
    assert variables == {'x': 'what'}

    variables = {}
    assert node.resolve('awhaty', variables) is ay_node
    assert variables == {'x': 'what'}
Exemple #20
0
def test_mixed_node():
    node = Node()
    step_node = node.add(Step("prefix{x}postfix"))

    variables = {}
    assert node.resolve("prefixfoopostfix", variables) is step_node
    assert variables == {"x": "foo"}

    variables = {}
    assert node.resolve("prefixbarpostfix", variables) is step_node
    assert variables == {"x": "bar"}

    variables = {}
    assert node.resolve("prefixwhat", variables) is None
    assert variables == {}
Exemple #21
0
def test_mixed_node():
    node = Node()
    step_node = node.add(Step('prefix{x}postfix'))

    variables = {}
    assert node.resolve('prefixfoopostfix', variables) is step_node
    assert variables == {'x': 'foo'}

    variables = {}
    assert node.resolve('prefixbarpostfix', variables) is step_node
    assert variables == {'x': 'bar'}

    variables = {}
    assert node.resolve('prefixwhat', variables) is None
    assert variables == {}
Exemple #22
0
def test_variable_node_specific_first():
    node = Node()
    x_node = node.add(Step('{x}'))
    prefix_node = node.add(Step('prefix{x}'))
    assert node.get('what') == (x_node, {'x': 'what'})
    assert node.get('prefixwhat') == (prefix_node, {'x': 'what'})
Exemple #23
0
def test_mixed_node():
    node = Node()
    step_node = node.add(Step('prefix{x}postfix'))
    assert node.get('prefixfoopostfix') == (step_node, {'x': 'foo'})
    assert node.get('prefixbarpostfix') == (step_node, {'x': 'bar'})
    assert node.get('prefixwhat') == (None, {})
Exemple #24
0
def test_variable_node():
    node = Node()
    step_node = node.add(Step('{x}'))
    assert node.get('foo') == (step_node, {'x': 'foo'})
    assert node.get('bar') == (step_node, {'x': 'bar'})
Exemple #25
0
def test_name_node():
    node = Node()
    step_node = node.add(Step('foo'))
    assert node.get('foo') == (step_node, {})
    assert node.get('bar') == (None, {})
Exemple #26
0
def test_variable_node_optional_colon():
    node = Node()
    x_node = node.add(Step("{x}"))
    xy_node = node.add(Step("{x}:{y}"))
    assert node.get("a") == (x_node, {"x": "a"})
    assert node.get("a:b") == (xy_node, {"x": "a", "y": "b"})
Exemple #27
0
def test_variable_node_optional_colon():
    node = Node()
    x_node = node.add(Step('{x}'))
    xy_node = node.add(Step('{x}:{y}'))
    assert node.get('a') == (x_node, {'x': 'a'})
    assert node.get('a:b') == (xy_node, {'x': 'a', 'y': 'b'})
Exemple #28
0
def test_variable_node_specific_first():
    node = Node()
    x_node = node.add(Step("{x}"))
    prefix_node = node.add(Step("prefix{x}"))
    assert node.get("what") == (x_node, {"x": "what"})
    assert node.get("prefixwhat") == (prefix_node, {"x": "what"})
Exemple #29
0
def test_mixed_node():
    node = Node()
    step_node = node.add(Step("prefix{x}postfix"))
    assert node.get("prefixfoopostfix") == (step_node, {"x": "foo"})
    assert node.get("prefixbarpostfix") == (step_node, {"x": "bar"})
    assert node.get("prefixwhat") == (None, {})
Exemple #30
0
def test_variable_node():
    node = Node()
    step_node = node.add(Step("{x}"))
    assert node.get("foo") == (step_node, {"x": "foo"})
    assert node.get("bar") == (step_node, {"x": "bar"})
Exemple #31
0
def test_name_node():
    node = Node()
    step_node = node.add(Step("foo"))
    assert node.get("foo") == (step_node, {})
    assert node.get("bar") == (None, {})
Exemple #32
0
def test_mixed_node():
    node = Node()
    step_node = node.add(Step('prefix{x}postfix'))
    assert node.get('prefixfoopostfix') == (step_node, {'x': 'foo'})
    assert node.get('prefixbarpostfix') == (step_node, {'x': 'bar'})
    assert node.get('prefixwhat') == (None, {})
Exemple #33
0
def test_variable_node():
    node = Node()
    step_node = node.add(Step('{x}'))
    assert node.get('foo') == (step_node, {'x': 'foo'})
    assert node.get('bar') == (step_node, {'x': 'bar'})
Exemple #34
0
def test_name_node():
    node = Node()
    step_node = node.add(Step('foo'))
    assert node.get('foo') == (step_node, {})
    assert node.get('bar') == (None, {})
Exemple #35
0
def test_variable_node_optional_colon():
    node = Node()
    x_node = node.add(Step('{x}'))
    xy_node = node.add(Step('{x}:{y}'))
    assert node.get('a') == (x_node, {'x': 'a'})
    assert node.get('a:b') == (xy_node, {'x': 'a', 'y': 'b'})
Exemple #36
0
def test_variable_node_specific_first():
    node = Node()
    x_node = node.add(Step('{x}'))
    prefix_node = node.add(Step('prefix{x}'))
    assert node.get('what') == (x_node, {'x': 'what'})
    assert node.get('prefixwhat') == (prefix_node, {'x': 'what'})