Esempio n. 1
0
def test_redirectors():
    n = Node('a', 'b', children=[Node('x', 'y')])
    list(n)
    to = To(n)

    to.stdout('hello there')

    n1 = to()
    assert n1 == n

    to.head.data('c')
    assert n.head.data == 'c'

    to.head.code('e')
    assert n.head.code == 'e'

    to.head.view('m')
    assert n.head.view == 'm'

    to.body.code('f')
    assert n.body.code == 'f'

    to.body.data('d')
    assert n.body.data == 'd'

    to.body.view('h')
    assert n.body.view == 'h'

    nc = n.children[0]
    assert nc.parent == n

    to = To(nc)
    to.parent.body.data('ko')
    assert n.body.data == 'ko'
Esempio n. 2
0
def test_sorting_levels():
    headline('sorting outlines')
    n1 = Node('h1', 'b1')
    n1.level = '1.3.1'
    n2 = Node('h2', 'b2')
    n2.level = '1.1'
    n3 = Node('h3', 'b3')
    n3.level = '1.2'
    nodes = [n1, n2, n3]
    print nodes
    print sorted(nodes)
    assert sorted(nodes)[0] == n2
Esempio n. 3
0
def test_complex_imports():
    n1 = imports_2
    standard(n1)
    assert n1.body.code
    n1.render()
    assert 't1' in n1.tree.namespace
    assert 'hello' in n1.body.data

    n2 = Node("h2", "@py upper(t1)")
    # standard(n2)
    assert n2.body.code
    assert 't1' in n2.tree.namespace
    assert n2.body.type == 'py-expr'
    n2.body.render()
    assert n2.body.view == "OK"
Esempio n. 4
0
def test_sorting_levels():
    headline("sorting outlines")
    n1 = Node("h1", "b1")
    n1.level = "1.3.1"
    n2 = Node("h2", "b2")
    n2.level = "1.1"
    n3 = Node("h3", "b3")
    n3.level = "1.2"
    nodes = [n1, n2, n3]
    print nodes
    print sorted(nodes)
    assert sorted(nodes)[0] == n2
Esempio n. 5
0
def test_sorting_levels():
    headline('sorting outlines')
    n1 = Node('h1', 'b1')
    n1.level = '1.3.1'
    n2 = Node('h2', 'b2')
    n2.level = '1.1'
    n3 = Node('h3', 'b3')
    n3.level = '1.2'
    nodes = [n1,n2,n3]
    print nodes
    print sorted(nodes)
    assert sorted(nodes)[0] == n2 
Esempio n. 6
0
 def test(directive):
     node = Node(directive)
     print directive, ':', node.head.view
Esempio n. 7
0
def node1(head, body=''):
    n = Node(head.lstrip(),
             '\n'.join([l.lstrip() for l in body.split('\n') if l]))
    return n
Esempio n. 8
0
def test_param_6():
    n = Node(head="@attr(handsome='devil')")
    n.head.render()
    assert n.attributes['handsome'] == 'devil'
    display(n)
Esempio n. 9
0
def test_param_5():
    n = Node(head="@xt('cheetah') 1 + $a")
    n.head.render()
    assert n.head.view == "1 + 2"
    display(n)
Esempio n. 10
0
def test_param_4():
    n = Node(head="@pipe(to='sky') 1 + 1")
    n.head.render()
    assert n.head.view == 2
    display(n)
Esempio n. 11
0
def test_param_3():
    n = Node(head="@tmpl(oops=32) they said $oops today")
    n.head.render()
    assert n.head.view == "they said 32 today"
    display(n)
Esempio n. 12
0
def test_param_2():
    n = Node(head="@py(b=2) b * 100")
    n.head.render()
    assert n.head.view == 200
    display(n)
Esempio n. 13
0
def test_param_1():
    n = Node(head="@hello('world')")
    n.head.render()
    assert n.head.view == 'hello world'
    display(n)
Esempio n. 14
0
    # display(n)


pipe_3 = node1("@pipe 'ok' | upper | to.body.data")


@register(pipe_3, 1, 0)
def test_pipe_3():
    n = pipe_3
    standard(n)
    n.render()
    assert n.body.data == 'OK'


pipe_4 = Node("@pipe node.children | sorted | to.children", "",
              [Node('a', 'c', level='3.1'),
               Node('b', 'd', level='1.1')])


@register(pipe_4, 1, 0)
def test_pipe_4():
    n = pipe_4
    standard(n)
    a = n.children[0].head.text
    assert a == 'a'
    n.render()
    b = n.children[0].head.text
    assert b == 'b'
    assert a != b