• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python _tests.update_item函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: setup_method

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


示例2: custom_setup

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


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


示例4: test_rename_acts_only_in_active_name_in_case_there_are_several_names

    def test_rename_acts_only_in_active_name_in_case_there_are_several_names(self):
        content = u"This is page content"

        update_item(u'Page',
                    {NAME: [u'First',
                            u'Second',
                            u'Third',
                            ],
                     CONTENTTYPE: u'text/x.moin.wiki;charset=utf-8'}, content)

        item = Item.create(u'Second')
        item.rename(u'New name', comment=u'renamed')

        item1 = Item.create(u'First')
        assert item1.name == u'First'
        assert item1.meta[CONTENTTYPE] == 'text/x.moin.wiki;charset=utf-8'
        assert item1.content.data == content

        item2 = Item.create(u'New name')
        assert item2.name == u'New name'
        assert item2.meta[CONTENTTYPE] == 'text/x.moin.wiki;charset=utf-8'
        assert item2.content.data == content

        item3 = Item.create(u'Third')
        assert item3.name == u'Third'
        assert item3.meta[CONTENTTYPE] == 'text/x.moin.wiki;charset=utf-8'
        assert item3.content.data == content

        assert item1.rev.revid == item2.rev.revid == item3.rev.revid

        item4 = Item.create(u'Second')
        assert item4.meta[CONTENTTYPE] == CONTENTTYPE_NONEXISTENT
开发者ID:denedios,项目名称:moin-2.0,代码行数:32,代码来源:test_Item.py


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


示例6: test_Include_Read_Permission_Denied

 def test_Include_Read_Permission_Denied(self):
     # attempt to include an item that user cannot read
     update_item(u'page1', {CONTENTTYPE: u'text/x.moin.wiki;charset=utf-8', ACL: u'All:write,create,admin,destroy'}, u'no one can read')
     update_item(u'page2', {CONTENTTYPE: u'text/x.moin.wiki;charset=utf-8'}, u'some text{{page1}}more text')
     page2 = Item.create(u'page2')
     rendered = page2.content._render_data()
     # an error message will follow p tag, similar to: Access Denied, transcluded content suppressed.
     assert '<div class="warning"><p>' in rendered
开发者ID:denedios,项目名称:moin-2.0,代码行数:8,代码来源:test_include.py


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


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


示例9: test_appending_group_item

    def test_appending_group_item(self):
        """
        Test scalability by appending a name to a large list of group members.
        """
        become_trusted()
        # long list of users
        members = create_random_string_list(length=15, count=1234)
        test_user = create_random_string_list(length=15, count=1)[0]
        update_item(u'UserGroup', {USERGROUP: members}, DATA)
        update_item(u'UserGroup', {USERGROUP: members + [test_user]}, '')
        result = test_user in flaskg.groups['UserGroup']

        assert result
开发者ID:rciorba,项目名称:moin-2.0-mirror,代码行数:13,代码来源:test_wiki_groups.py


示例10: test_IncludeHandlesCircularRecursion

 def test_IncludeHandlesCircularRecursion(self):
     # detect circular recursion and create error message
     update_item(u'page1', {CONTENTTYPE: u'text/x.moin.wiki;charset=utf-8'}, u'{{page2}}')
     update_item(u'page2', {CONTENTTYPE: u'text/x.moin.wiki;charset=utf-8'}, u'{{page3}}')
     update_item(u'page3', {CONTENTTYPE: u'text/x.moin.wiki;charset=utf-8'}, u'{{page4}}')
     update_item(u'page4', {CONTENTTYPE: u'text/x.moin.wiki;charset=utf-8'}, u'{{page2}}')
     page1 = Item.create(u'page1')
     rendered = page1.content._render_data()
     # an error message will follow strong tag
     assert '<strong class="moin-error">' in rendered
开发者ID:gitpraetorianlabs,项目名称:moin-2.0,代码行数:10,代码来源:test_include.py


示例11: test_global_atom_with_an_item

    def test_global_atom_with_an_item(self, app):
        basename = u'Foo'
        update_item(basename, {COMMENT: u"foo data for feed item"}, '')
        with app.test_client() as c:
            rv = c.get(url_for('feed.atom'))
            assert rv.status == '200 OK'
            assert rv.headers['Content-Type'] == 'application/atom+xml'
            assert rv.data.startswith('<?xml')
            assert "foo data for feed item" in rv.data

        # tests the cache invalidation
        update_item(basename, {COMMENT: u"checking if the cache invalidation works"}, '')
        with app.test_client() as c:
            rv = c.get(url_for('feed.atom'))
            assert rv.status == '200 OK'
            assert rv.headers['Content-Type'] == 'application/atom+xml'
            assert rv.data.startswith('<?xml')
            assert "checking if the cache invalidation works" in rv.data
开发者ID:denedios,项目名称:moin-2.0,代码行数:18,代码来源:test_feed.py


示例12: test_IncludeHandlesCircularRecursion

    def test_IncludeHandlesCircularRecursion(self):
        # issue #80
        # we use MoinWiki items to make tests simple
        update_item(u'page1', {CONTENTTYPE: u'text/x.moin.wiki'}, u'{{page2}}')
        update_item(u'page2', {CONTENTTYPE: u'text/x.moin.wiki'}, u'{{page3}}')
        update_item(u'page3', {CONTENTTYPE: u'text/x.moin.wiki'}, u'{{page4}}')
        update_item(u'page4', {CONTENTTYPE: u'text/x.moin.wiki'}, u'{{page2}}')

        page1 = MoinWiki.create(u'page1')
        rendered = page1._render_data()
        # an error message will follow strong tag
        assert '<strong class="moin-error">' in rendered
开发者ID:pombredanne,项目名称:moin2,代码行数:12,代码来源:test_include.py


示例13: test_item_can_have_several_names

    def test_item_can_have_several_names(self):
        content = u"This is page content"

        update_item(u'Page',
                    {NAME: [u'Page',
                            u'Another name',
                            ],
                     CONTENTTYPE: u'text/x.moin.wiki;charset=utf-8'}, content)

        item1 = Item.create(u'Page')
        assert item1.name == u'Page'
        assert item1.meta[CONTENTTYPE] == 'text/x.moin.wiki;charset=utf-8'
        assert item1.content.data == content

        item2 = Item.create(u'Another name')
        assert item2.name == u'Another name'
        assert item2.meta[CONTENTTYPE] == 'text/x.moin.wiki;charset=utf-8'
        assert item2.content.data == content

        assert item1.rev.revid == item2.rev.revid
开发者ID:denedios,项目名称:moin-2.0,代码行数:20,代码来源:test_Item.py


示例14: test_wiki_backend_item_acl_usergroupmember_item

    def test_wiki_backend_item_acl_usergroupmember_item(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 an item group and check acl rights
        """
        become_trusted()
        update_item(u'NewGroup', {USERGROUP: ["ExampleUser"]}, DATA)

        acl_rights = ["NewGroup:read,write"]
        acl = AccessControlList(acl_rights, valid=app.cfg.acl_rights_contents)

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

        # update item - add AnotherUser to a item group NewGroup
        update_item(u'NewGroup', {USERGROUP: ["AnotherUser"]}, '')

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

        assert not has_rights_before, 'AnotherUser has no read rights because in the beginning he is not a member of a group item NewGroup'
        assert has_rights_after, 'AnotherUser must have read rights because after appenditem he is member of NewGroup'
开发者ID:rciorba,项目名称:moin-2.0-mirror,代码行数:21,代码来源:test_wiki_groups.py


示例15: test__render_data_diff

 def test__render_data_diff(self):
     item_name = u'Html_Item'
     empty_html = u'<span></span>'
     html = u'<span>\ud55c</span>'
     meta = {CONTENTTYPE: u'text/html;charset=utf-8'}
     item = Item.create(item_name)
     item._save(meta, empty_html)
     item = Item.create(item_name)
     # Unicode test, html escaping
     rev1 = update_item(item_name, meta, html)
     rev2 = update_item(item_name, {}, u'     ')
     result = Text._render_data_diff(item.content, rev1, rev2)
     assert escape(html) in result
     # Unicode test, whitespace
     rev1 = update_item(item_name, {}, u'\n\n')
     rev2 = update_item(item_name, {}, u'\n     \n')
     result = Text._render_data_diff(item.content, rev1, rev2)
     assert '<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>' in result
     # If fairly similar diffs are correctly spanned or not, also check indent
     rev1 = update_item(item_name, {}, u'One Two Three Four\nSix\n\ud55c')
     rev2 = update_item(item_name, {}, u'Two Three Seven Four\nSix\n\ud55c')
     result = Text._render_data_diff(item.content, rev1, rev2)
     assert '<span>One </span>Two Three Four' in result
     assert 'Two Three <span>Seven </span>Four' in result
     # Check for diff_html.diff return types
     assert reduce(lambda x, y: x and y, [isinstance(i[1], unicode) and isinstance(i[3], unicode) for i in diff_html.diff(u'One Two Three Four\nSix\n', u'Two Three Seven Four\nSix Seven\n')], True)
开发者ID:denedios,项目名称:moin-2.0,代码行数:26,代码来源:test_Content.py


示例16: test_ExternalInclude

 def test_ExternalInclude(self):
     # external include
     update_item(u"page1", {CONTENTTYPE: u"text/x.moin.wiki;charset=utf-8"}, u"{{http://moinmo.in}}")
     rendered = Item.create(u"page1").content._render_data()
     assert (
         '<object class="moin-http moin-transclusion" data="http://moinmo.in" data-href="http://moinmo.in">http://moinmo.in</object>'
         in rendered
     )
     # external include embedded within text (object is an inline tag)
     update_item(u"page1", {CONTENTTYPE: u"text/x.moin.wiki;charset=utf-8"}, u"before {{http://moinmo.in}} after")
     rendered = Item.create(u"page1").content._render_data()
     assert (
         '<p>before <object class="moin-http moin-transclusion" data="http://moinmo.in" data-href="http://moinmo.in">http://moinmo.in</object> after</p>'
         in rendered
     )
     # external include embedded within text italic and bold markup (object is an inline tag)
     update_item(
         u"page1",
         {CONTENTTYPE: u"text/x.moin.wiki;charset=utf-8"},
         u"before ''italic '''bold {{http://moinmo.in}} bold''' italic'' normal",
     )
     rendered = Item.create(u"page1").content._render_data()
     assert (
         '<p>before <em>italic <strong>bold <object class="moin-http moin-transclusion" data="http://moinmo.in" data-href="http://moinmo.in">http://moinmo.in</object> bold</strong> italic</em> normal</p>'
         in rendered
     )
开发者ID:rciorba,项目名称:moin-2.0-mirror,代码行数:26,代码来源:test_include.py


示例17: test_InlineIncludeImage

 def test_InlineIncludeImage(self):
     # the 3rd parameter, u'',  should be a binary string defining a png image, but it is not needed for this simple test
     update_item(u"logo.png", {CONTENTTYPE: u"image/png"}, u"")
     # simple transclusion
     update_item(u"page1", {CONTENTTYPE: u"text/x.moin.wiki;charset=utf-8"}, u"{{logo.png}}")
     rendered = Item.create(u"page1").content._render_data()
     assert '<p><span class="moin-transclusion" data-href="/logo.png"><img alt="logo.png" src=' in rendered
     assert '/logo.png" /></span></p>' in rendered
     # within paragraph
     update_item(u"page1", {CONTENTTYPE: u"text/x.moin.wiki;charset=utf-8"}, u"text {{logo.png}} text")
     rendered = Item.create(u"page1").content._render_data()
     assert '<p>text <span class="moin-transclusion" data-href="/logo.png"><img alt="logo.png" src=' in rendered
     assert '/logo.png" /></span> text</p>' in rendered
     # within markup
     update_item(
         u"page1",
         {CONTENTTYPE: u"text/x.moin.wiki;charset=utf-8"},
         u"Normal ''italic '''bold {{logo.png}} bold''' italic'' normal",
     )
     rendered = Item.create(u"page1").content._render_data()
     assert (
         '<p>Normal <em>italic <strong>bold <span class="moin-transclusion" data-href="/logo.png"><img alt="logo.png" src='
         in rendered
     )
     assert '/logo.png" /></span> bold</strong> italic</em> normal</p>' in rendered
     # multiple transclusions
     update_item(u"page1", {CONTENTTYPE: u"text/x.moin.wiki;charset=utf-8"}, u"{{logo.png}}{{logo.png}}")
     rendered = Item.create(u"page1").content._render_data()
     assert '<p><span class="moin-transclusion" data-href="/logo.png"><img alt="logo.png" src=' in rendered
     assert (
         '/logo.png" /></span><span class="moin-transclusion" data-href="/logo.png"><img alt="logo.png" src='
         in rendered
     )
     # check for old bug
     assert "<p />" not in rendered
     assert "<p></p>" not in rendered
开发者ID:rciorba,项目名称:moin-2.0-mirror,代码行数:36,代码来源:test_include.py


示例18: test_InlineIncludeLogo

    def test_InlineIncludeLogo(self):
        # the 3rd parameter, u'',  should be a binary string defining a png image, but it is not needed for this simple test
        update_item(u'logo', {CONTENTTYPE: u'image/png'}, u'')

        update_item(u'page1', {CONTENTTYPE: u'text/x.moin.wiki'}, u'{{logo}}')
        rendered = MoinWiki.create(u'page1')._render_data()
        assert '<img alt="logo" class="moin-transclusion"' in rendered

        # <p /> is not valid html5; should be <p></p>. to be valid.  Even better, there should be no empty p's.
        update_item(u'page1', {CONTENTTYPE: u'text/x.moin.wiki'}, u'{{logo}}{{logo}}')
        rendered = MoinWiki.create(u'page1')._render_data()
        assert '<p />' not in rendered
        assert '<p></p>' not in rendered
开发者ID:pombredanne,项目名称:moin2,代码行数:13,代码来源:test_include.py


示例19: test_member_removed_from_group_item

    def test_member_removed_from_group_item(self):
        """
        Tests appending a member to a large list of group members and
        recreating the item without the member.
        """
        become_trusted()

        # long list of users
        members = create_random_string_list()
        update_item(u'UserGroup', {USERGROUP: members}, DATA)

        # updates the text with the text_user
        test_user = create_random_string_list(length=15, count=1)[0]
        update_item(u'UserGroup', {USERGROUP: [test_user]}, DATA)
        result = test_user in flaskg.groups[u'UserGroup']
        assert result

        # updates the text without test_user
        update_item(u'UserGroup', {}, DATA)
        result = test_user in flaskg.groups[u'UserGroup']
        assert not result
开发者ID:rciorba,项目名称:moin-2.0-mirror,代码行数:21,代码来源:test_wiki_groups.py


示例20: test_rename_recursion

    def test_rename_recursion(self):
        update_item(u'Page', {CONTENTTYPE: u'text/x.moin.wiki;charset=utf-8'}, u'Page 1')
        update_item(u'Page/Child', {CONTENTTYPE: u'text/x.moin.wiki;charset=utf-8'}, u'this is child')
        update_item(u'Page/Child/Another', {CONTENTTYPE: u'text/x.moin.wiki;charset=utf-8'}, u'another child')

        item = Item.create(u'Page')
        item.rename(u'Renamed_Page', comment=u'renamed')

        # items at original name and its contents after renaming
        item = Item.create(u'Page')
        assert item.name == u'Page'
        assert item.meta[CONTENTTYPE] == CONTENTTYPE_NONEXISTENT
        item = Item.create(u'Page/Child')
        assert item.name == u'Page/Child'
        assert item.meta[CONTENTTYPE] == CONTENTTYPE_NONEXISTENT
        item = Item.create(u'Page/Child/Another')
        assert item.name == u'Page/Child/Another'
        assert item.meta[CONTENTTYPE] == CONTENTTYPE_NONEXISTENT

        # item at new name and its contents after renaming
        item = Item.create(u'Renamed_Page')
        assert item.name == u'Renamed_Page'
        assert item.meta[NAME_OLD] == [u'Page']
        assert item.meta[COMMENT] == u'renamed'
        assert item.content.data == u'Page 1'

        item = Item.create(u'Renamed_Page/Child')
        assert item.name == u'Renamed_Page/Child'
        assert item.meta[NAME_OLD] == [u'Page/Child']
        assert item.meta[COMMENT] == u'renamed'
        assert item.content.data == u'this is child'

        item = Item.create(u'Renamed_Page/Child/Another')
        assert item.name == u'Renamed_Page/Child/Another'
        assert item.meta[NAME_OLD] == [u'Page/Child/Another']
        assert item.meta[COMMENT] == u'renamed'
        assert item.content.data == u'another child'
开发者ID:denedios,项目名称:moin-2.0,代码行数:37,代码来源:test_Item.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python action.AttachFile类代码示例发布时间:2022-05-24
下一篇:
Python _tests.nuke_page函数代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap