Esempio n. 1
0
def test_nav_block_returns_tree_relative_to_children(tree):
    assert len(tree.get_children()) == 2

    block = PageNavigationBlock(
        origin=PageNavigationBlock.RELATIVE_FROM_CHILDREN)

    nav_tree = block.get_page_tree(tree.get_children()[0])
    assert len(nav_tree) == 1
    assert nav_tree[0][0].node.path == '000100010001'
    assert nav_tree[0][0].node.name == 'node-1-1'

    nav_tree = block.get_page_tree(tree.get_children()[1])
    assert len(nav_tree) == 2
    assert nav_tree[0][0].node.path == '000100020001'
    assert nav_tree[0][0].node.name == 'node-2-1'
    assert nav_tree[1][0].node.path == '000100020002'
    assert nav_tree[1][0].node.name == 'node-2-2'
def test_nav_block_returns_tree_relative_to_children(tree):
    assert len(tree.get_children()) == 2

    block = PageNavigationBlock(
        origin=PageNavigationBlock.RELATIVE_FROM_CHILDREN)

    nav_tree = block.get_page_tree(tree.get_children()[0])
    assert len(nav_tree) == 1
    assert nav_tree[0][0].node.path == '000100010001'
    assert nav_tree[0][0].node.name == 'node-1-1'

    nav_tree = block.get_page_tree(tree.get_children()[1])
    assert len(nav_tree) == 2
    assert nav_tree[0][0].node.path == '000100020001'
    assert nav_tree[0][0].node.name == 'node-2-1'
    assert nav_tree[1][0].node.path == '000100020002'
    assert nav_tree[1][0].node.name == 'node-2-2'
Esempio n. 3
0
def test_nav_block_returns_tree_relative_to_siblings(index, tree):
    block = PageNavigationBlock(
        origin=PageNavigationBlock.RELATIVE_FROM_SIBLINGS)

    nav_tree = block.get_page_tree(tree.get_children()[index])
    assert len(nav_tree) == 2
    assert nav_tree[0][0].node.path == '00010001'
    assert nav_tree[0][0].node.name == 'node-1'
    assert nav_tree[1][0].node.path == '00010002'
    assert nav_tree[1][0].node.name == 'node-2'
def test_nav_block_returns_tree_relative_to_siblings(index, tree):
    block = PageNavigationBlock(
        origin=PageNavigationBlock.RELATIVE_FROM_SIBLINGS)

    nav_tree = block.get_page_tree(tree.get_children()[index])
    assert len(nav_tree) == 2
    assert nav_tree[0][0].node.path == '00010001'
    assert nav_tree[0][0].node.name == 'node-1'
    assert nav_tree[1][0].node.path == '00010002'
    assert nav_tree[1][0].node.name == 'node-2'
Esempio n. 5
0
def test_nav_block_returns_tree_absolute(depth, tree):
    block = PageNavigationBlock(depth=depth,
                                origin=PageNavigationBlock.ABSOLUTE)
    nav_tree = block.get_page_tree(tree.get_children()[0])

    assert len(nav_tree) == 1
    assert nav_tree[0][0].node.path == '0001'
    assert nav_tree[0][0].node.name == 'root'

    if depth == 2:
        assert len(nav_tree[0]) == 2
        assert nav_tree[0][1][0][0].node.path == '00010001'
        assert nav_tree[0][1][0][0].node.name == 'node-1'
        assert nav_tree[0][1][1][0].node.path == '00010002'
        assert nav_tree[0][1][1][0].node.name == 'node-2'
def test_nav_block_returns_tree_absolute(depth, tree):
    block = PageNavigationBlock(
        depth=depth, origin=PageNavigationBlock.ABSOLUTE)
    nav_tree = block.get_page_tree(tree.get_children()[0])

    assert len(nav_tree) == 1
    assert nav_tree[0][0].node.path == '0001'
    assert nav_tree[0][0].node.name == 'root'

    if depth == 2:
        assert len(nav_tree[0]) == 2
        assert nav_tree[0][1][0][0].node.path == '00010001'
        assert nav_tree[0][1][0][0].node.name == 'node-1'
        assert nav_tree[0][1][1][0].node.path == '00010002'
        assert nav_tree[0][1][1][0].node.name == 'node-2'
Esempio n. 7
0
def test_page_navigation_block_return_empty_list_if_no_page():
    block = PageNavigationBlock()
    assert block.get_page_tree(None) == []
def test_page_navigation_block_return_empty_list_if_no_page():
    block = PageNavigationBlock()
    assert block.get_page_tree(None) == []