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


Python _tests.become_trusted函数代码示例

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


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

示例1: test_validjson

def test_validjson():
    """
    Tests for changes to metadata when modifying an item.

    Does not apply to usersettings form.
    """
    app.cfg.namespace_mapping = [(u'', 'default_backend'), (u'ns1/', 'default_backend'), (u'ns1/ns2/', 'other_backend')]
    item = Item.create(u'ns1/ns2/existingname')
    meta = {NAMESPACE: u'ns1/ns2', CONTENTTYPE: u'text/plain;charset=utf-8'}
    become_trusted()
    item._save(meta, data='This is a valid Item.')

    valid_itemid = 'a1924e3d0a34497eab18563299d32178'
    # ('names', 'namespace', 'field', 'value', 'result')
    tests = [([u'somename', u'@revid'], '', '', 'somename', False),  # item names cannot begin with @
             # TODO for above? - create item @x, get error message, change name in meta to xx, get an item with names @40x and alias of xx
             ([u'bar', u'ns1'], '', '', 'bar', False),  # item names cannot match namespace names
             ([u'foo', u'foo', u'bar'], '', '', 'foo', False),  # names in the name list must be unique.
             ([u'ns1ns2ns3', u'ns1/subitem'], '', '', 'valid', False),  # Item names must not match with existing namespaces; items cannot be in 2 namespaces
             ([u'foobar', u'validname'], '', ITEMID, valid_itemid + '8080', False),  # attempts to change itemid in meta result in "Item(s) named foobar, validname already exist."
             ([u'barfoo', u'validname'], '', ITEMID, valid_itemid.replace('a', 'y'), False),  # similar to above
             ([], '', 'itemid', valid_itemid, True),  # deleting all names from the metadata of an existing item will make it nameless, succeeds
             ([u'existingname'], 'ns1/ns2', '', 'existingname', False),  # item already exists
            ]
    for name, namespace, field, value, result in tests:
        meta = {NAME: name, NAMESPACE: namespace}
        x = JSON(json.dumps(meta))
        y = Names(name)
        state = dict(fqname=CompositeName(namespace, field, value), itemid=None, meta=meta)
        value = x.validate(state) and y.validate(state)
        assert value == result
开发者ID:denedios,项目名称:moin-2.0,代码行数:31,代码来源:test_forms.py

示例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)
开发者ID:Kartstig,项目名称:engineering-inventions-wiki,代码行数:26,代码来源:test_cache.py

示例3: setup_method

 def setup_method(self, method):
     become_trusted(username=u'WikiAdmin')
     for item_names, item_acl, item_content in self.items:
         meta = {NAME: item_names}
         if item_acl is not None:
             meta.update({ACL: item_acl})
         update_item(item_names[0], meta, item_content)
开发者ID:rciorba,项目名称:moin-2.0-mirror,代码行数:7,代码来源:test_security.py

示例4: 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

示例5: 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

示例6: custom_setup

 def custom_setup(self):
     become_trusted(username=u"WikiAdmin")
     for item_names, item_acl, item_content in self.items:
         meta = {NAME: item_names}
         if item_acl is not None:
             meta.update({ACL: item_acl})
         update_item(item_names[0], meta, item_content)
开发者ID:yask123,项目名称:moinmoin,代码行数:7,代码来源:test_security.py

示例7: test_validjson

def test_validjson():
    app.cfg.namespace_mapping = [(u'', 'default_backend'), (u'ns1/', 'default_backend'), (u'ns1/ns2/', 'other_backend')]
    item = Item.create(u'ns1/ns2/existingname')
    meta = {NAMESPACE: u'ns1/ns2', CONTENTTYPE: u'text/plain;charset=utf-8'}
    become_trusted()
    item._save(meta, data='This is a valid Item.')

    valid_itemid = 'a1924e3d0a34497eab18563299d32178'
    # ('names', 'namespace', 'field', 'value', 'result')
    tests = [([u'somename', u'@revid'], '', '', 'somename', False),
             ([u'bar', u'ns1'], '', '', 'bar', False),
             ([u'foo', u'foo', u'bar'], '', '', 'foo', False),
             ([u'ns1ns2ns3', u'ns1/subitem'], '', '', 'valid', False),
             ([u'foobar', u'validname'], '', ITEMID, valid_itemid + '8080', False),
             ([u'barfoo', u'validname'], '', ITEMID, valid_itemid.replace('a', 'y'), False),
             ([], '', 'itemid', valid_itemid, True),
             ([u'existingname'], 'ns1/ns2', '', 'existingname', False),
             ]
    for name, namespace, field, value, result in tests:
        meta = {NAME: name, NAMESPACE: namespace}
        x = JSON(json.dumps(meta))
        y = Names(name)
        state = dict(fqname=CompositeName(namespace, field, value), itemid=None, meta=meta)
        value = x.validate(state) and y.validate(state)
        assert value == result
开发者ID:gitpraetorianlabs,项目名称:moin-2.0,代码行数:25,代码来源:test_forms.py

示例8: test_dict

    def test_dict(self):
        become_trusted()
        somedict = {u"One": u"1",
                    u"Two": u"2"}
        update_item(u'TestDict', {SOMEDICT: somedict}, "This is a dict item.")

        return u"TestDict"
开发者ID:denedios,项目名称:moin-2.0,代码行数:7,代码来源:test_GetVal.py

示例9: setup_method

 def setup_method(self, method):
     # temporary hack till we apply test cleanup mechanism on tests.
     self.app, self.ctx = init_test_app(wikiconfig.Config)
     become_trusted()
     somedict = {u"One": u"1",
                 u"Two": u"2"}
     update_item(u'TestDict', {SOMEDICT: somedict}, DATA)
开发者ID:pombredanne,项目名称:moin2,代码行数:7,代码来源:test_GetVal.py

示例10: 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

示例11: 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

示例12: testGetValAfterADictPageIsDeleted

 def testGetValAfterADictPageIsDeleted(self):
     """ macro GetVal test: 'reads Dict var after another Dict is removed' """
     request = self.request
     become_trusted(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'), page)
     nuke_page(request, u'SomeDict')
     assert result == "This is a brand new example"
开发者ID:Kartstig,项目名称:engineering-inventions-wiki,代码行数:10,代码来源:test_GetVal.py

示例13: 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

示例14: setup_method

    def setup_method(self, method):
        become_trusted()

        somedict = {u"First": u"first item",
                    u"text with spaces": u"second item",
                    u'Empty string': u'',
                    u"Last": u"last item"}
        update_item(u'SomeTestDict', {SOMEDICT: somedict}, DATA)

        somedict = {u"One": u"1",
                    u"Two": u"2"}
        update_item(u'SomeOtherTestDict', {SOMEDICT: somedict}, DATA)
开发者ID:pombredanne,项目名称:moin2,代码行数:12,代码来源:test_wiki_dicts.py

示例15: test_rename_group_item

    def test_rename_group_item(self):
        """
        Tests renaming of a group item.
        """
        become_trusted()
        item = update_item(u'SomeGroup', {USERGROUP: ["ExampleUser"]}, DATA)
        assert u'ExampleUser' in flaskg.groups[u'SomeGroup']
        pytest.raises(GroupDoesNotExistError, lambda: flaskg.groups[u'AnotherGroup'])

        item = update_item(u'SomeGroup', {NAME: [u'AnotherGroup', ], USERGROUP: ["ExampleUser"]}, DATA)
        assert u'ExampleUser' in flaskg.groups[u'AnotherGroup']
        pytest.raises(GroupDoesNotExistError, lambda: flaskg.groups[u'SomeGroup'])
开发者ID:rciorba,项目名称:moin-2.0-mirror,代码行数:12,代码来源:test_wiki_groups.py


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