Commit 6d0dc567 authored by Jérome Perrin's avatar Jérome Perrin

add some tests for the asContext method



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@11079 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 849f4c68
......@@ -1024,6 +1024,29 @@ class TestPropertySheet:
self.assertEquals('The organisation title',
person.getDefaultOrganisationTitle())
def test_AsContext(self):
"""asContext method return a temporary copy of an object.
Any modification made to the copy does not change the original object.
"""
obj = self.getPersonModule().newContent(portal_type='Person')
obj.setTitle('obj title')
copy = obj.asContext()
copy.setTitle('copy title')
self.assertEquals('obj title', obj.getTitle())
self.assertEquals('copy title', copy.getTitle())
# asContext method accepts parameters, and edit the copy with those
# parameters
obj = self.getPersonModule().newContent(portal_type='Person', id='obj')
obj.setTitle('obj title')
copy = obj.asContext(title='copy title')
self.assertEquals('obj title', obj.getTitle())
self.assertEquals('copy title', copy.getTitle())
# acquisition context is the same
self.assertEquals(self.getPersonModule(), obj.aq_parent)
self.assertEquals(self.getPersonModule(), copy.aq_parent)
if __name__ == '__main__':
framework()
else:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment