当前位置: 首页>>代码示例>>Python>>正文


Python _tests.create_page函数代码示例

本文整理汇总了Python中MoinMoin._tests.create_page函数的典型用法代码示例。如果您正苦于以下问题:Python create_page函数的具体用法?Python create_page怎么用?Python create_page使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了create_page函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_wiki_backend_page_acl_append_page

    def test_wiki_backend_page_acl_append_page(self):
        """
        Test if the wiki group backend works with acl code.
        First check acl rights of a user that is not a member of group
        then add user member to a page group and check acl rights
        """
        request = self.request
        become_trusted(request)

        create_page(request, u'NewGroup', u" * ExampleUser")

        acl_rights = ["NewGroup:read,write"]
        acl = security.AccessControlList(request.cfg, acl_rights)

        has_rights_before = acl.may(request, u"AnotherUser", "read")

        # update page - add AnotherUser to a page group NewGroup
        append_page(request, u'NewGroup', u" * AnotherUser")

        has_rights_after = acl.may(request, u"AnotherUser", "read")

        nuke_page(request, u'NewGroup')

        assert not has_rights_before, 'AnotherUser has no read rights because in the beginning he is not a member of a group page NewGroup'
        assert has_rights_after, 'AnotherUser must have read rights because after appendage he is member of NewGroup'
开发者ID:Kartstig,项目名称:engineering-inventions-wiki,代码行数:25,代码来源:test_wiki_groups.py

示例2: setup_class

    def setup_class(cls):
        request = cls.request
        become_trusted(request)

        for page, text in cls.pages.iteritems():
            if text:
                create_page(request, page, text)
开发者ID:Kartstig,项目名称:engineering-inventions-wiki,代码行数:7,代码来源:test_search.py

示例3: test_attachment

    def test_attachment(self):
        page_name = u'TestAttachment'
        self.pages[page_name] = 'some text' # Moin search must search this page

        filename = "AutoCreatedSillyAttachmentForSearching.png"
        data = "Test content"
        filecontent = StringIO.StringIO(data)

        result = self.search(filename)
        found_attachments = set([(hit.page_name, hit.attachment) for hit in result.hits])
        assert not found_attachments

        try:
            create_page(self.request, page_name, self.pages[page_name])
            AttachFile.add_attachment(self.request, page_name, filename, filecontent, True)
            append_page(self.request, page_name, '[[attachment:%s]]' % filename)
            self._index_update()
            result = self.search(filename)
            found_attachments = set([(hit.page_name, hit.attachment) for hit in result.hits])
            assert (page_name, '') in found_attachments
            assert 1 <= len(found_attachments) <= 2
            # Note: moin search returns (page_name, '') as only result
            #       xapian search returns 2 results: (page_name, '') and (page_name, filename)
            # TODO: make behaviour the same, if possible
        finally:
            nuke_page(self.request, page_name)
            del self.pages[page_name]
            self._index_update()
            result = self.search(filename)
            found_attachments = set([(hit.page_name, hit.attachment) for hit in result.hits])
            assert not found_attachments
开发者ID:Kartstig,项目名称:engineering-inventions-wiki,代码行数:31,代码来源:test_search.py

示例4: test_cache_key_attachment

    def test_cache_key_attachment(self):
        request = self.request
        pagename = self.pagename
        attachname = 'foo.txt'

        become_trusted(request)
        create_page(request, pagename, u"Foo!")

        AttachFile.add_attachment(request, pagename, attachname, "Test content1", True)

        result1 = cache.key(request, itemname=pagename, attachname=attachname, secret='bar')
        result2 = cache.key(request, itemname=pagename, attachname=attachname, secret='baz')
        assert result1  # not empty
        assert result1 != result2  # different for different secret

        # test below does not work, because mtime is often same, inode can be same due to how add_attachment
        # works, file size is same, attachment name is same, wikiname/pagename is same.
        # In practice, this should rather rarely cause problems:
        #AttachFile.add_attachment(request, pagename, attachname, "Test content2", True)
        #result3 = cache.key(request, itemname=pagename, attachname=attachname, secret='baz')
        #assert result3 != result2  # different for different content

        AttachFile.add_attachment(request, pagename, attachname, "Test content33333", True)
        result4 = cache.key(request, itemname=pagename, attachname=attachname, secret='baz')
        assert len(result4) == len(result2)  # same length of key for different input lengths
        nuke_page(request, pagename)
开发者ID:Kartstig,项目名称:engineering-inventions-wiki,代码行数:26,代码来源:test_cache.py

示例5: setup_class

    def setup_class(self):
        # Backup user
        self.savedUser = self.request.user.name
        self.request.user = User(self.request, auth_username=u'WikiAdmin')
        self.request.user.valid = True

        for page_name, page_content in self.pages:
            create_page(self.request, page_name, page_content)
开发者ID:steveyen,项目名称:moingo,代码行数:8,代码来源:test_security.py

示例6: testGetValAfterADictPageIsDeleted

 def testGetValAfterADictPageIsDeleted(self):
     """ macro GetVal test: 'reads Dict var after another Dict is removed' """
     request = self.request
     page = create_page(request, u'SomeDict', u" EXAMPLE:: This is an example text")
     page.deletePage()
     page = create_page(request, self.pagename, u' VAR:: This is a brand new example')
     result = self._test_macro(u'GetVal', "%s,%s" % (self.pagename, u'VAR'))
     nuke_page(request, u'SomeDict')
     assert result == "This is a brand new example"
开发者ID:steveyen,项目名称:moingo,代码行数:9,代码来源:test_GetVal.py

示例7: get_members

    def get_members(self, text):
        request = self.request
        formatter = Formatter(self.request)

        become_trusted(request)
        create_page(request, u'TestPageGroup', text)
        page = Page(request, 'TestPageGroup', formatter=formatter)
        page.send_page(content_only=True)
        nuke_page(request, u'TestPageGroup')

        return formatter.members
开发者ID:Glottotopia,项目名称:aagd,代码行数:11,代码来源:test_groups.py

示例8: test_add_attachment

    def test_add_attachment(self):
        """Test if add_attachment() works"""

        become_trusted(self.request)
        filename = "AutoCreatedSillyAttachment"

        create_page(self.request, self.pagename, u"Foo!")

        AttachFile.add_attachment(self.request, self.pagename, filename, "Test content", True)
        exists = AttachFile.exists(self.request, self.pagename, filename)

        nuke_page(self.request, self.pagename)

        assert exists
开发者ID:steveyen,项目名称:moingo,代码行数:14,代码来源:test_attachfile.py

示例9: test_create_page

 def test_create_page(self):
     expected_pages = set([u'TestCreatePage', ])
     self.pages['TestCreatePage'] = 'some text' # Moin search must search this page
     try:
         create_page(self.request, 'TestCreatePage', self.pages['TestCreatePage'])
         self._index_update()
         result = self.search(u'-domain:underlay -domain:system TestCreatePage')
         found_pages = set([hit.page_name for hit in result.hits])
         assert found_pages == expected_pages
     finally:
         nuke_page(self.request, 'TestCreatePage')
         self._index_update()
         del self.pages['TestCreatePage']
         result = self.search(u'-domain:underlay -domain:system TestCreatePage')
         found_pages = set([hit.page_name for hit in result.hits])
         assert not found_pages
开发者ID:Kartstig,项目名称:engineering-inventions-wiki,代码行数:16,代码来源:test_search.py

示例10: testGetValACLs

 def testGetValACLs(self):
     """ macro GetVal test: 'cant read VAR on an ACL protected page' """
     py.test.skip("user has no rights to create acl pages")
     page = create_page(self.request, self.pagename,
                        '#acl SomeUser:read,write All:delete\n VAR:: This is an example')
     result = self._test_macro(u'GetVal', "%s,%s" % (self.pagename, u'VAR'), page)
     assert result == "&lt;&lt;GetVal: You don't have enough rights on this page&gt;&gt;"
开发者ID:Kartstig,项目名称:engineering-inventions-wiki,代码行数:7,代码来源:test_GetVal.py

示例11: test_create_page

 def test_create_page(self):
     expected_pages = set([u"TestCreatePage"])
     self.pages["TestCreatePage"] = "some text"  # Moin search must search this page
     try:
         create_page(self.request, "TestCreatePage", self.pages["TestCreatePage"])
         self._index_update()
         result = self.search(u"-domain:underlay -domain:system TestCreatePage")
         found_pages = set([hit.page_name for hit in result.hits])
         assert found_pages == expected_pages
     finally:
         nuke_page(self.request, "TestCreatePage")
         self._index_update()
         del self.pages["TestCreatePage"]
         result = self.search(u"-domain:underlay -domain:system TestCreatePage")
         found_pages = set([hit.page_name for hit in result.hits])
         assert not found_pages
开发者ID:Glottotopia,项目名称:aagd,代码行数:16,代码来源:test_search.py

示例12: test_appending_group_page

    def test_appending_group_page(self):
        """
        Test scalability by appending a name to a large list of group members.
        """
        request = self.request
        become_trusted(request)

        # long list of users
        page_content = [u" * %s" % member for member in create_random_string_list(length=15, count=1234)]
        test_user = create_random_string_list(length=15, count=1)[0]
        create_page(request, u'UserGroup', "\n".join(page_content))
        append_page(request, u'UserGroup', u' * %s' % test_user)
        result = test_user in request.groups['UserGroup']
        nuke_page(request, u'UserGroup')

        assert result
开发者ID:Kartstig,项目名称:engineering-inventions-wiki,代码行数:16,代码来源:test_wiki_groups.py

示例13: setup_class

 def setup_class(self):
     request = self.request
     become_trusted(request)
     self.page = create_page(request, self.pagename, u"Foo!")
     # for that test eventlog needs to be empty
     nuke_eventlog(request)
     # hits is based on hitcounts which reads the cache
     caching.CacheEntry(request, 'charts', 'hitcounts', scope='wiki').remove()
开发者ID:Kartstig,项目名称:engineering-inventions-wiki,代码行数:8,代码来源:test_Hits.py

示例14: testActionCallingRaw

 def testActionCallingRaw(self):
     """ module_tested: executes raw by macro Action on existing page"""
     request = self.request
     become_trusted(request)
     self.page = create_page(request, self.pagename, u'= title1 =\n||A||B||\n')
     m = make_macro(self.request, self.page)
     result = Action.macro_Action(m, 'raw')
     nuke_page(request, self.pagename)
     expected = '<a class="action" href="/AutoCreatedMoinMoinTemporaryTestPageForAction?action=raw">raw</a>'
     assert result == expected
开发者ID:Glottotopia,项目名称:aagd,代码行数:10,代码来源:test_Action.py

示例15: test_add_attachment_for_file_object

    def test_add_attachment_for_file_object(self):
        """Test if add_attachment() works with file like object"""

        become_trusted(self.request)

        filename = "AutoCreatedSillyAttachment.png"

        create_page(self.request, self.pagename, u"FooBar!")
        data = "Test content"

        filecontent = StringIO.StringIO(data)

        AttachFile.add_attachment(self.request, self.pagename, filename, filecontent, True)
        exists = AttachFile.exists(self.request, self.pagename, filename)
        path = AttachFile.getAttachDir(self.request, self.pagename)
        imagef = os.path.join(path, filename)
        file_size = os.path.getsize(imagef)

        nuke_page(self.request, self.pagename)

        assert exists and file_size == len(data)
开发者ID:steveyen,项目名称:moingo,代码行数:21,代码来源:test_attachfile.py


注:本文中的MoinMoin._tests.create_page函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。