本文整理汇总了Python中MoinMoin._tests.nuke_page函数的典型用法代码示例。如果您正苦于以下问题:Python nuke_page函数的具体用法?Python nuke_page怎么用?Python nuke_page使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了nuke_page函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: 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
示例2: 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)
示例3: 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'
示例4: 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"
示例5: 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
示例6: test_get_attachment_path_created_on_getFilename
def test_get_attachment_path_created_on_getFilename(self):
"""
Tests if AttachFile.getFilename creates the attachment dir on self.requesting
"""
filename = ""
file_exists = os.path.exists(AttachFile.getFilename(self.request, self.pagename, filename))
nuke_page(self.request, self.pagename)
assert file_exists
示例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
示例8: test_rename_group_page
def test_rename_group_page(self):
"""
Tests if the groups cache is refreshed after renaming a Group page.
"""
request = self.request
become_trusted(request)
page = create_page(request, u'SomeGroup', u" * ExampleUser")
page.renamePage('AnotherGroup')
result = u'ExampleUser' in request.groups[u'AnotherGroup']
nuke_page(request, u'AnotherGroup')
assert result is True
示例9: 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
示例10: test_simple_group_page
def test_simple_group_page(self):
"""
Tests if a simple group page is evaluated correctly.
"""
request = self.request
become_trusted(request)
group_name = u'SimpleGroup'
page_text = u"""\
* FirstUser
* SecondUser
* LastUser"""
page = create_page(request, group_name, page_text)
group_members = set(request.groups[group_name])
assert group_members == set([u'FirstUser', u'SecondUser', u'LastUser'])
nuke_page(request, group_name)
示例11: testAttachments_without_page_creation
def testAttachments_without_page_creation(self):
become_trusted(self.request)
pagename = u"PackageAttachmentAttachWithoutPageCreation"
script = u"""MoinMoinPackage|1
AddAttachment|1_attachment|my_test.txt|%(pagename)s
Print|Thank you for using PackagePages!
""" % {"pagename": pagename}
zip_file = self.create_package(script)
package = ZipPackage(self.request, zip_file)
package.installPackage()
assert not Page(self.request, pagename).exists()
assert AttachFile.exists(self.request, pagename, "my_test.txt")
nuke_page(self.request, pagename)
os.unlink(zip_file)
示例12: testRenameGroupPage
def testRenameGroupPage(self):
"""
tests if the dict cache for groups is refreshed after renaming a Group page
"""
request = self.request
become_trusted(request)
page = create_page(request, u'SomeGroup', u" * ExampleUser")
page.renamePage('AnotherGroup')
group = wikidicts.Group(request, '')
isgroup = request.cfg.cache.page_group_regexact.search
grouppages = request.rootpage.getPageList(user='', filter=isgroup)
result = request.dicts.has_member(u'AnotherGroup', u'ExampleUser')
nuke_page(request, u'AnotherGroup')
assert result is True
示例13: testAppendingGroupPage
def testAppendingGroupPage(self):
"""
tests scalability by appending a name to a large list of group members
"""
# long list of users
page_content = [u" * %s" % member for member in create_random_string_list(length=15, count=30000)]
request = self.request
become_trusted(request)
test_user = create_random_string_list(length=15, count=1)[0]
page = create_page(request, u'UserGroup', "\n".join(page_content))
page = append_page(request, u'UserGroup', u' * %s' % test_user)
result = request.dicts.has_member('UserGroup', test_user)
nuke_page(request, u'UserGroup')
assert result is True
示例14: 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
示例15: 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