本文整理汇总了Python中MoinMoin.items.Item类的典型用法代码示例。如果您正苦于以下问题:Python Item类的具体用法?Python Item怎么用?Python Item使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Item类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: 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
示例2: test_rename
def test_rename(self):
name = u'Test_Item'
contenttype = u'text/plain;charset=utf-8'
data = 'test_data'
meta = {'test_key': 'test_value', CONTENTTYPE: contenttype}
comment = u'saved it'
item = Item.create(name)
item._save(meta, data, comment=comment)
# item and its contents before renaming
item = Item.create(name)
assert item.name == u'Test_Item'
assert item.meta[COMMENT] == u'saved it'
new_name = u'Test_new_Item'
item.rename(new_name, comment=u'renamed')
# item at original name and its contents after renaming
item = Item.create(name)
assert item.name == u'Test_Item'
# this should be a fresh, new item, NOT the stuff we renamed:
assert item.meta[CONTENTTYPE] == CONTENTTYPE_NONEXISTENT
# item at new name and its contents after renaming
item = Item.create(new_name)
assert item.name == u'Test_new_Item'
assert item.meta[NAME_OLD] == [u'Test_Item']
assert item.meta[COMMENT] == u'renamed'
assert item.content.data == u'test_data'
开发者ID:denedios,项目名称:moin-2.0,代码行数:25,代码来源:test_Item.py
示例3: test_rename_recursion_with_multiple_names_and_children
def test_rename_recursion_with_multiple_names_and_children(self):
update_item(u'Foo', {
CONTENTTYPE: u'text/x.moin.wiki;charset=utf-8',
NAME: [u'Other', u'Page', u'Foo'],
}, u'Parent')
update_item(u'Page/Child', {CONTENTTYPE: u'text/x.moin.wiki;charset=utf-8'}, u'Child of Page')
update_item(u'Other/Child2', {CONTENTTYPE: u'text/x.moin.wiki;charset=utf-8'}, u'Child of Other')
update_item(u'Another', {
CONTENTTYPE: u'text/x.moin.wiki;charset=utf-8',
NAME: [u'Another', u'Page/Second'],
}, u'Both')
update_item(u'Page/Second/Child', {CONTENTTYPE: u'text/x.moin.wiki;charset=utf-8'}, u'Child of Second')
update_item(u'Another/Child', {CONTENTTYPE: u'text/x.moin.wiki;charset=utf-8'}, u'Child of Another')
item = Item.create(u'Page')
item.rename(u'Renamed', comment=u'renamed')
assert Item.create(u'Page/Child').meta[CONTENTTYPE] == CONTENTTYPE_NONEXISTENT
assert Item.create(u'Renamed/Child').content.data == u'Child of Page'
assert Item.create(u'Page/Second').meta[CONTENTTYPE] == CONTENTTYPE_NONEXISTENT
assert Item.create(u'Renamed/Second').content.data == u'Both'
assert Item.create(u'Another').content.data == u'Both'
assert Item.create(u'Page/Second/Child').meta[CONTENTTYPE] == CONTENTTYPE_NONEXISTENT
assert Item.create(u'Renamed/Second/Child').content.data == u'Child of Second'
assert Item.create(u'Other/Child2').content.data == u'Child of Other'
assert Item.create(u'Another/Child').content.data == u'Child of Another'
开发者ID:denedios,项目名称:moin-2.0,代码行数:27,代码来源:test_Item.py
示例4: 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> </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
示例5: 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
# simple transclusion with alt text and width
update_item(u'page1', {CONTENTTYPE: u'text/x.moin.wiki;charset=utf-8'}, u'{{logo.png|my alt text|width="100"}}')
rendered = Item.create(u'page1').content._render_data()
assert '<p><span class="moin-transclusion" data-href="/logo.png"><img alt="my alt text" src=' in rendered
assert 'logo.png" width="100" /></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:gitpraetorianlabs,项目名称:moin-2.0,代码行数:31,代码来源:test_include.py
示例6: test_get_content_diff
def test_get_content_diff(self):
item = self.imw[self.item_name]
rev1 = item.store_revision(dict(name=[self.item_name, ], contenttype='text/plain'),
StringIO(u'x'), trusted=True, return_rev=True)
notification = Notification(app, self.item_name, [rev1], action=ACTION_SAVE)
assert notification.get_content_diff() == ["+ x"]
rev1.data.seek(0, 0)
rev2 = item.store_revision(dict(name=[self.item_name, ], contenttype='text/plain'),
StringIO(u'xx'), trusted=True, return_rev=True)
notification = Notification(app, self.item_name, [rev2, rev1], action=ACTION_SAVE)
assert notification.get_content_diff() == ['- x', '+ xx']
rev2.data.seek(0, 0)
notification = Notification(app, self.item_name, [rev2, rev1], action=ACTION_TRASH)
assert notification.get_content_diff() == ['- xx']
rev2.data.seek(0, 0)
item = Item.create(self.item_name)
notification = Notification(app, self.item_name, [], content=item.rev.data,
meta=rev2.meta, action=DESTROY_REV)
assert notification.get_content_diff() == ['- xx']
rev2.data.seek(0, 0)
item = Item.create(self.item_name)
notification = Notification(app, self.item_name, [], content=item.rev.data,
meta=rev2.meta, action=DESTROY_ALL)
assert notification.get_content_diff() == ['- xx']
开发者ID:rciorba,项目名称:moin-2.0-mirror,代码行数:28,代码来源:test_notifications.py
示例7: test_rename
def test_rename(self):
name = u'Test_Item'
contenttype = u'text/plain;charset=utf-8'
data = 'test_data'
meta = {'test_key': 'test_value', CONTENTTYPE: contenttype}
comment = u'saved it'
item = Item.create(name)
item._save(meta, data, comment=comment)
# item and its contents before renaming
item = Item.create(name)
assert item.name == u'Test_Item'
assert item.meta['comment'] == u'saved it'
new_name = u'Test_new_Item'
item.rename(new_name, comment=u'renamed')
# item at original name and its contents after renaming
item = Item.create(name)
assert item.name == u'Test_Item'
# this should be a fresh, new item, NOT the stuff we renamed:
assert item.meta[CONTENTTYPE] == 'application/x-nonexistent'
# item at new name and its contents after renaming
item = Item.create(new_name)
assert item.name == u'Test_new_Item'
assert item.meta['name_old'] == u'Test_Item'
assert item.meta['comment'] == u'renamed'
assert item.data == u'test_data'
开发者ID:pombredanne,项目名称:moin2,代码行数:25,代码来源:test_Item.py
示例8: testIndexOnDisconnectedLevels
def testIndexOnDisconnectedLevels(self):
# create a toplevel and some sub-items
basename = u'Bar'
for name in ['', '/ab', '/ab/cd/ef/gh', '/ij/kl/mn/op', '/ij/kl/rs']:
item = Item.create(basename + name)
item._save({CONTENTTYPE: u'text/plain;charset=utf-8'}, "foo")
baseitem = Item.create(basename)
index = baseitem.get_index()
index = baseitem._connect_levels(index)
assert index == [(u'Bar/ab', u'ab', u'text/plain;charset=utf-8'),
(u'Bar/ab/cd', u'ab/cd', u'application/x-nonexistent'),
(u'Bar/ab/cd/ef', u'ab/cd/ef', u'application/x-nonexistent'),
(u'Bar/ab/cd/ef/gh', u'ab/cd/ef/gh', u'text/plain;charset=utf-8'),
(u'Bar/ij', u'ij', u'application/x-nonexistent'),
(u'Bar/ij/kl', u'ij/kl', u'application/x-nonexistent'),
(u'Bar/ij/kl/mn', u'ij/kl/mn', u'application/x-nonexistent'),
(u'Bar/ij/kl/mn/op', u'ij/kl/mn/op', u'text/plain;charset=utf-8'),
(u'Bar/ij/kl/rs', u'ij/kl/rs', u'text/plain;charset=utf-8')]
flat_index = baseitem.flat_index()
assert flat_index == [(u'Bar/ab', u'ab', u'text/plain;charset=utf-8'),
(u'Bar/ij', u'ij', u'application/x-nonexistent'),
]
开发者ID:pombredanne,项目名称:moin2,代码行数:25,代码来源:test_Item.py
示例9: 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
示例10: test_subscriptions
def test_subscriptions(self):
pagename = u"Foo:foo 123"
tagname = u"xxx"
regexp = r"\d+"
item = Item.create(pagename)
item._save({NAMESPACE: u"", TAGS: [tagname]})
item = Item.create(pagename)
meta = item.meta
name = u'bar'
password = name
email = "[email protected]"
user.create_user(name, password, email)
the_user = user.User(name=name, password=password)
assert not the_user.is_subscribed_to(item)
the_user.subscribe(NAME, u"SomeOtherPageName", u"")
result = the_user.unsubscribe(NAME, u"OneMorePageName", u"")
assert result is False
subscriptions = [(ITEMID, meta[ITEMID], None),
(NAME, pagename, meta[NAMESPACE]),
(TAGS, tagname, meta[NAMESPACE]),
(NAMEPREFIX, pagename[:4], meta[NAMESPACE]),
(NAMERE, regexp, meta[NAMESPACE])]
for subscription in subscriptions:
keyword, value, namespace = subscription
the_user.subscribe(keyword, value, namespace)
assert the_user.is_subscribed_to(item)
the_user.unsubscribe(keyword, value, namespace, item)
assert not the_user.is_subscribed_to(item)
开发者ID:denedios,项目名称:moin-2.0,代码行数:30,代码来源:test_user.py
示例11: test_meta_dict_to_text
def test_meta_dict_to_text(self):
name = u'Test_item'
contenttype = u'text/plain;charset=utf-8'
meta = {'test_key': 'test_val', CONTENTTYPE: contenttype, NAME: [u'test_name']}
item = Item.create(name)
result = Item.meta_dict_to_text(item, meta)
expected = '{\n "contenttype": "text/plain;charset=utf-8", \n "test_key": "test_val"\n}'
assert result == expected
开发者ID:denedios,项目名称:moin-2.0,代码行数:8,代码来源:test_Item.py
示例12: test_meta_text_to_dict
def test_meta_text_to_dict(self):
name = u'Test_item'
contenttype = u'text/plain;charset=utf-8'
text = '{\n "contenttype": "text/plain;charset=utf-8", \n "test_key": "test_val", \n "name": ["test_name"] \n}'
item = Item.create(name)
result = Item.meta_text_to_dict(item, text)
expected = {'test_key': 'test_val', CONTENTTYPE: contenttype}
assert result == expected
开发者ID:denedios,项目名称:moin-2.0,代码行数:8,代码来源:test_Item.py
示例13: test_create
def test_create(self):
item = Item.create(self.name, itemtype=ITEMTYPE_BLOG)
item._save(self.meta, self.data, comment=self.comment)
# check save result
item = Item.create(self.name)
assert isinstance(item, Blog)
assert item.itemtype == ITEMTYPE_BLOG
assert item.meta[CONTENTTYPE] == self.contenttype
开发者ID:denedios,项目名称:moin-2.0,代码行数:8,代码来源:test_Blog.py
示例14: setup_method
def setup_method(self, method):
# create an item
self.item_name = u"foo"
self.tagname = u"XXX"
self.namespace = NAMESPACE_DEFAULT
meta = {CONTENTTYPE: u"text/plain;charset=utf-8", TAGS: [self.tagname]}
item = Item.create(self.item_name)
item._save(meta)
self.item = Item.create(self.item_name)
开发者ID:rciorba,项目名称:moin-2.0-mirror,代码行数:9,代码来源:test_subscriptions.py
示例15: test_meta_filter
def test_meta_filter(self):
name = u'Test_item'
contenttype = u'text/plain;charset=utf-8'
meta = {'test_key': 'test_val', CONTENTTYPE: contenttype, NAME: [u'test_name'], ADDRESS: u'1.2.3.4'}
item = Item.create(name)
result = Item.meta_filter(item, meta)
# keys like NAME, ITEMID, REVID, DATAID are filtered
expected = {'test_key': 'test_val', CONTENTTYPE: contenttype}
assert result == expected
开发者ID:denedios,项目名称:moin-2.0,代码行数:9,代码来源:test_Item.py
示例16: test_do_show
def test_do_show(self):
# create a blog item
item = Item.create(self.blog_name, itemtype=ITEMTYPE_BLOG)
item._save(self.blog_meta, self.blog_data, comment=self.comment)
# create a blog entry item
item = Item.create(self.entry_name, itemtype=ITEMTYPE_BLOG_ENTRY)
item._save(self.entry_meta, self.entry_data, comment=self.comment)
data_tokens = [self.blog_data, self.entry_data, ]
self._test_view(self.entry_name, data_tokens=data_tokens)
开发者ID:denedios,项目名称:moin-2.0,代码行数:10,代码来源:test_Blog.py
示例17: test__get_data_diff_html
def test__get_data_diff_html(self):
item_name = u"Test_Item"
item = Item.create(item_name)
contenttype = u'text/plain;charset=utf-8'
meta = {CONTENTTYPE: contenttype}
item._save(meta)
item_ = Item.create(item_name)
oldfile = BytesIO("")
newfile = BytesIO("x")
difflines = item_.content._get_data_diff_html(oldfile, newfile)
assert difflines == [(1, Markup(u''), 1, Markup(u'<span>x</span>'))]
开发者ID:denedios,项目名称:moin-2.0,代码行数:11,代码来源:test_Content.py
示例18: test_do_show_entries
def test_do_show_entries(self):
item = Item.create(self.name, itemtype=ITEMTYPE_BLOG)
item._save(self.meta, self.data, comment=self.comment)
# store entries without PTIME
for entry in self.entries:
item = Item.create(entry['name'], itemtype=ITEMTYPE_BLOG_ENTRY)
item._save(self.entry_meta, entry['data'], comment=self.comment)
# the blog is not empty
exclude_data_tokens = [self.NO_ENTRIES_MSG, ]
# all stored blog entries are listed on the blog index page
data_tokens = [self.data, ] + [entry['data'] for entry in self.entries]
self._test_view(self.name, data_tokens=data_tokens, exclude_data_tokens=exclude_data_tokens)
开发者ID:denedios,项目名称:moin-2.0,代码行数:12,代码来源:test_Blog.py
示例19: test_revert
def test_revert(self):
name = u'Test_Item'
contenttype = u'text/plain;charset=utf-8'
data = 'test_data'
meta = {'test_key': 'test_value', CONTENTTYPE: contenttype}
comment = u'saved it'
item = Item.create(name)
item._save(meta, data, comment=comment)
item = Item.create(name)
item.revert(u'revert')
item = Item.create(name)
assert item.meta[ACTION] == ACTION_REVERT
开发者ID:denedios,项目名称:moin-2.0,代码行数:12,代码来源:test_Item.py
示例20: test__transform
def test__transform(self):
item_name = u'image_Item'
item = Item.create(item_name)
contenttype = u'image/jpeg'
meta = {CONTENTTYPE: contenttype}
item._save(meta)
item = Item.create(item_name)
try:
from PIL import Image as PILImage
with pytest.raises(ValueError):
result = TransformableBitmapImage._transform(item.content, 'text/plain')
except ImportError:
result = TransformableBitmapImage._transform(item.content, contenttype)
assert result == (u'image/jpeg', '')
开发者ID:denedios,项目名称:moin-2.0,代码行数:14,代码来源:test_Content.py
注:本文中的MoinMoin.items.Item类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论