Ejemplo n.º 1
0
def test_page_unicode_representation():
    settings.TEST_TIME = datetime(1999, 1, 1)
    u = User(username='******')
    u.save()

    p = Page(
        title='Foobar',
        slug='foo',
        content='blah',
        publish_time=datetime(1998, 1, 2),
        created_by=u,
        last_modified_by=u,
        )
    p.save()

    eq(unicode(p), u'Foobar')
Ejemplo n.º 2
0
def test_manager_unpublished_page():
    settings.TEST_TIME = datetime(1999, 1, 1)
    u = User(username='******')
    u.save()

    p = Page(
        title='Foobar',
        slug='foo',
        content='blah',
        publish_time=datetime(1999, 1, 2),
        created_by=u,
        last_modified_by=u,
        )
    p.save()

    eq(Page.online_pages.all().count(), 0)
Ejemplo n.º 3
0
def test_view_page():
    u = User(username='******')
    u.save()

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

    c = Client()
    response = c.get('/first/')
    eq(response.status_code, 200)

    assert 'first' in response.content
    assert 'blah' in response.content
Ejemplo n.º 4
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
Ejemplo n.º 5
0
def test_nav_order():
    u = User(username='******')
    u.save()

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

    p2 = Page(
        title='first',
        slug='bar',
        content='blah',
        created_by=u,
        last_modified_by=u,
        nav_order=5,
        )
    p2.save()

    pages = Page.objects.all()
    eq(pages[0].title, 'first')
    eq(pages[1].title, 'second')
Ejemplo n.º 6
0
def test_path_traversal_404_on_unpublished():
    u = User(username='******')
    u.save()

    p = Page(
        title='first',
        slug='first',
        content='blah',
        created_by=u,
        last_modified_by=u,
        hidden=True,
        )
    p.save()

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

    assert_raises(
        Http404,
        traverse_for_page,
        '/first/second/',
        Page.online_pages,
        )
Ejemplo n.º 7
0
def test_path_traversal_404_on_not_found():
    u = User(username='******')
    u.save()

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

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

    assert_raises(
        Http404,
        traverse_for_page,
        '/first/third/',
        Page.objects,
        )
Ejemplo n.º 8
0
def test_path_traversal():
    u = User(username='******')
    u.save()

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

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

    page = traverse_for_page('/first/second/', Page.objects)
    eq(page.title, 'second')