예제 #1
0
    def test_backlinks(self):
        page = model.WikiContent(title="test", body="[[foo]], [[bar]]")
        page.put()
        self.assertEquals(page.links, ["foo", "bar"])

        page2 = model.WikiContent(title="foo", body=None)
        self.assertEquals(page2.get_backlinks()[0].title, page.title)
예제 #2
0
 def test_page_listing(self):
     self.assertEquals(util.wikify('[[List:foo]]'), '')
     model.WikiContent(
         title='bar',
         body='labels: foo\n---\n# bar\n\nHello, world.').put()
     model.WikiContent(
         title='baz',
         body='labels: foo\n---\n# baz\n\nHello, world.').put()
     self.assertEquals(
         util.wikify('[[List:foo]]'),
         u'<ul class="labellist"><li><a class="int" href="/bar" title="bar">bar</a></li><li><a class="int" href="/baz" title="baz">baz</a></li></ul>'
     )
예제 #3
0
    def test_page_redirect(self):
        """Makes sure that redirects are supported when displaying pages."""
        if not TEST_VIEWS:
            return
        page1 = model.WikiContent(title='page1',
                                  body='redirect: page2\n---\n# page1')
        page1.put()

        page2 = model.WikiContent(title='page2', body='# page2')
        page2.put()

        html = view.view_page(page1)
        print html
예제 #4
0
    def test_children_listing(self):
        self.assertEquals(len(model.WikiContent.get_all()), 0)

        model.WikiContent(title='foo/bar').put()
        model.WikiContent(title='foo/baz').put()
        self.assertEquals(len(model.WikiContent.get_all()), 2)

        self.assertEquals(
            util.wikify('[[ListChildren:foo]]'),
            u'<ul class="labellist"><li><a class="int" href="/foo/bar" title="foo/bar">foo/bar</a></li><li><a class="int" href="/foo/baz" title="foo/baz">foo/baz</a></li></ul>'
        )
        self.assertEquals(
            util.wikify('[[ListChildren:]]', 'foo'),
            u'<ul class="labellist"><li><a class="int" href="/foo/bar" title="foo/bar">foo/bar</a></li><li><a class="int" href="/foo/baz" title="foo/baz">foo/baz</a></li></ul>'
        )
예제 #5
0
    def test_labelled_page_creation(self):
        self.assertEquals(len(model.WikiContent.get_all()), 0)

        page = model.WikiContent(title='foo')
        page.put()

        self.assertEquals(len(model.WikiContent.get_all()), 1)
        self.assertEquals(len(model.WikiContent.get_by_label('foo')), 0)

        page.body = 'labels: foo, bar\n---\n# foo'
        page.put()

        self.assertEquals(len(model.WikiContent.get_all()), 1)
        self.assertEquals(len(model.WikiContent.get_by_label('foo')), 1)
예제 #6
0
 def test_page_creation(self):
     self.assertEquals(len(model.WikiContent.get_all()), 0)
     model.WikiContent(title='foo').put()
     self.assertEquals(len(model.WikiContent.get_all()), 1)
예제 #7
0
    def test_underscores_in_titles(self):
        p1 = model.WikiContent(title='Hello World')
        p1.put()

        p2 = model.WikiContent.get_by_title('Hello_World')
        self.assertEquals(p1.key(), p2.key())
예제 #8
0
    def test_page_reading(self):
        user = users.User('*****@*****.**')

        # Unknown user, default access.
        settings.change({
            'open-reading': None,
            'readers': None,
            'editors': None
        })
        self.assertEquals(access.can_read_page('foo', user, False), True)

        # Unknown user, private wiki.
        settings.change({'open-reading': 'no'})
        self.assertEquals(access.can_read_page('foo', user, False), False)

        # A privilaged reader, private wiki.
        settings.change({
            'open-reading': 'no',
            'readers': user.email(),
            'editors': None
        })
        self.assertEquals(access.can_read_page('foo', user, False), True)

        # A privilaged editor, private wiki.
        settings.change({
            'open-reading': 'no',
            'readers': None,
            'editors': user.email()
        })
        self.assertEquals(access.can_read_page('foo', user, False), True)

        page = model.WikiContent(title='foo')

        # An unknown user, a private wiki and a public page.
        settings.change({
            'open-reading': 'no',
            'readers': None,
            'editors': None
        })
        page.body = 'public: yes\n---\n# foo'
        page.put()
        self.assertEquals(access.can_read_page('foo', user, False), True)

        # An unknown user, an open wiki and a private page.
        settings.change({
            'open-reading': 'yes',
            'readers': None,
            'editors': None
        })
        page.body = 'private: yes\n---\n# foo'
        page.put()
        self.assertEquals(access.can_read_page('foo', user, False), False)

        # An open wiki, a private page with explicit access to some regular user.
        settings.change({
            'open-reading': 'yes',
            'readers': None,
            'editors': None
        })
        page.body = 'private: yes\nreaders: %s\n---\n# foo' % user.email()
        page.put()
        self.assertEquals(access.can_read_page('foo', user, False), True)
예제 #9
0
 def test_edit_locked_page(self):
     """Make sure that locked pages aren't editable."""
     model.WikiContent(title='foo', body='locked: yes\n---\n# foo').put()
     settings.change({'open-editing': 'yes', 'open-reading': 'yes'})
     self.assertEquals(access.can_edit_page('foo', is_admin=False), False)