Exemplo n.º 1
0
def test_recurse_for_nav():
    u = User(username='******')
    u.save()

    p = Page(
        title='Foobar',
        slug='foo',
        content='blah',
        created_by=u,
        last_modified_by=u,
        )
    p.save()

    p2 = Page(
        parent=p,
        title='child1',
        slug='bar',
        content='blah',
        created_by=u,
        last_modified_by=u,
        )
    p2.save()

    p3 = Page(
        parent=p,
        title='child2',
        slug='baz',
        content='blah',
        created_by=u,
        last_modified_by=u,
        )
    p3.save()

    root = p.get_nav()
    eq(root.page.title, 'Foobar')

    eq(len(root.children), 2)

    child_titles = [c.page.title for c in root.children]
    assert 'child1' in child_titles
    assert 'child2' in child_titles