コード例 #1
0
ファイル: test_leonode.py プロジェクト: aliakhouri/leofunc
def test_redirectors():
    n = Node('a','b')
    n.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'
コード例 #2
0
ファイル: test_leonode.py プロジェクト: aliakhouri/leofunc
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]
    if VERBOSE:
        print nodes
        print sorted(nodes)
    assert sorted(nodes)[0] == n2 
コード例 #3
0
ファイル: test_leonode.py プロジェクト: aliakhouri/leofunc
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"
コード例 #4
0
ファイル: test_leonode.py プロジェクト: aliakhouri/leofunc
 def test(directive):
     node = Node(directive)
     if VERBOSE:
         print directive,':', node.head.view
コード例 #5
0
ファイル: test_leonode.py プロジェクト: aliakhouri/leofunc
def test_param_6():
    n = Node(head="@attr(handsome='devil')")
    n.head.render()
    assert n.attributes['handsome'] == 'devil'
    if VERBOSE: display(n)
コード例 #6
0
ファイル: test_leonode.py プロジェクト: aliakhouri/leofunc
def test_param_5():
    n = Node(head="@xt('cheetah') 1 + $a")
    n.head.render()
    assert n.head.view == "1 + 2"
    if VERBOSE: display(n)
コード例 #7
0
ファイル: test_leonode.py プロジェクト: aliakhouri/leofunc
def test_param_4():
    n = Node(head="@pipe(to='sky') 1 + 1")
    n.head.render()
    assert n.head.view == 2
    if VERBOSE: display(n)
コード例 #8
0
ファイル: test_leonode.py プロジェクト: aliakhouri/leofunc
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"
    if VERBOSE: display(n)
コード例 #9
0
ファイル: test_leonode.py プロジェクト: aliakhouri/leofunc
def node1(head, body=''):
    n = Node(
        head.lstrip(), 
        '\n'.join([l.lstrip() for l in body.split('\n') if l])
    )
    return n
コード例 #10
0
ファイル: test_leonode.py プロジェクト: aliakhouri/leofunc
def test_param_2():
    n = Node(head="@py(b=2) b * 100")
    n.head.render()
    assert n.head.view == 200
    if VERBOSE: display(n)
コード例 #11
0
ファイル: test_leonode.py プロジェクト: aliakhouri/leofunc
def test_param_1():
    n = Node(head="@hello('world')")
    n.head.render()
    assert n.head.view == 'hello world' 
    if VERBOSE: display(n)
コード例 #12
0
ファイル: test_leonode.py プロジェクト: aliakhouri/leofunc
    "@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",
    "")
pipe_4.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