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)
评论列表
文章目录