本文整理汇总了Python中trac.attachment.Attachment.reparent方法的典型用法代码示例。如果您正苦于以下问题:Python Attachment.reparent方法的具体用法?Python Attachment.reparent怎么用?Python Attachment.reparent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trac.attachment.Attachment
的用法示例。
在下文中一共展示了Attachment.reparent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_reparent
# 需要导入模块: from trac.attachment import Attachment [as 别名]
# 或者: from trac.attachment.Attachment import reparent [as 别名]
def test_reparent(self):
attachment1 = Attachment(self.env, 'wiki', 'SomePage')
attachment1.insert('foo.txt', StringIO(''), 0)
path1 = attachment1.path
attachment2 = Attachment(self.env, 'wiki', 'SomePage')
attachment2.insert('bar.jpg', StringIO(''), 0)
attachments = Attachment.select(self.env, 'wiki', 'SomePage')
self.assertEqual(2, len(list(attachments)))
attachments = Attachment.select(self.env, 'ticket', 123)
self.assertEqual(0, len(list(attachments)))
assert os.path.exists(path1) and os.path.exists(attachment2.path)
attachment1.reparent('ticket', 123)
self.assertEqual('ticket', attachment1.parent_realm)
self.assertEqual('ticket', attachment1.resource.parent.realm)
self.assertEqual('123', attachment1.parent_id)
self.assertEqual('123', attachment1.resource.parent.id)
attachments = Attachment.select(self.env, 'wiki', 'SomePage')
self.assertEqual(1, len(list(attachments)))
attachments = Attachment.select(self.env, 'ticket', 123)
self.assertEqual(1, len(list(attachments)))
assert not os.path.exists(path1) and os.path.exists(attachment1.path)
assert os.path.exists(attachment2.path)
示例2: test_reparent
# 需要导入模块: from trac.attachment import Attachment [as 别名]
# 或者: from trac.attachment.Attachment import reparent [as 别名]
def test_reparent(self):
attachment1 = Attachment(self.env, "wiki", "SomePage")
attachment1.insert("foo.txt", StringIO(""), 0)
path1 = attachment1.path
attachment2 = Attachment(self.env, "wiki", "SomePage")
attachment2.insert("bar.jpg", StringIO(""), 0)
attachments = Attachment.select(self.env, "wiki", "SomePage")
self.assertEqual(2, len(list(attachments)))
attachments = Attachment.select(self.env, "ticket", 123)
self.assertEqual(0, len(list(attachments)))
assert os.path.exists(path1) and os.path.exists(attachment2.path)
attachment1.reparent("ticket", 123)
self.assertEqual("ticket", attachment1.parent_realm)
self.assertEqual("ticket", attachment1.resource.parent.realm)
self.assertEqual("123", attachment1.parent_id)
self.assertEqual("123", attachment1.resource.parent.id)
attachments = Attachment.select(self.env, "wiki", "SomePage")
self.assertEqual(1, len(list(attachments)))
attachments = Attachment.select(self.env, "ticket", 123)
self.assertEqual(1, len(list(attachments)))
assert not os.path.exists(path1) and os.path.exists(attachment1.path)
assert os.path.exists(attachment2.path)