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


Python Attachment.reparent方法代码示例

本文整理汇总了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)
开发者ID:dafrito,项目名称:trac-mirror,代码行数:27,代码来源:attachment.py

示例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)
开发者ID:zjj,项目名称:trac_hack,代码行数:27,代码来源:attachment.py


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