test_mptt.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:health-mosconi 作者: GNUHealth-Mosconi 项目源码 文件源码
def test0060_update_only_if_parent_is_modified(self):
        'The left and right fields must only be updated if parent is modified'
        with Transaction().start(DB_NAME, USER, context=CONTEXT):
            records = self.mptt.search([
                    ('parent', '=', None),
                    ])
            with patch.object(self.mptt, '_update_tree') as mock:
                self.mptt.write(records, {'name': 'Parent Records'})
                self.assertFalse(mock.called)

                first_parent, second_parent = records[:2]
                self.mptt.write(list(first_parent.childs), {
                        'parent': second_parent.id,
                        })

                self.assertTrue(mock.called)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号