Back to index

plone3  3.1.7
Public Member Functions
Archetypes.tests.test_rename.RenameTests Class Reference
Inheritance diagram for Archetypes.tests.test_rename.RenameTests:
Inheritance graph
[legend]
Collaboration diagram for Archetypes.tests.test_rename.RenameTests:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def afterSetUp
def beforeTearDown
def test_rename
def getCounts
def test_recursive

Detailed Description

Definition at line 111 of file test_rename.py.


Member Function Documentation

Definition at line 113 of file test_rename.py.

00113 
00114     def afterSetUp(self):
00115         ATSiteTestCase.afterSetUp(self)
00116         for c in counts:
00117             c.reset()
00118         for name, meth in meths.items():
00119             wrap_method(BaseContent, name, meth, pattern='__test_%s__')

Here is the call graph for this function:

Definition at line 120 of file test_rename.py.

00120 
00121     def beforeTearDown(self):
00122         ATSiteTestCase.beforeTearDown(self)
00123         for name in meths.keys():
00124             unwrap_method(BaseContent, name)

Here is the call graph for this function:

Definition at line 146 of file test_rename.py.

00146 
00147     def getCounts(self, obj):
00148         uid = UID(obj)
00149         return (ADD_COUNTER.get(uid),
00150                 DELETE_COUNTER.get(uid),
00151                 CLONE_COUNTER.get(uid))

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 152 of file test_rename.py.

00152 
00153     def test_recursive(self):
00154         # Test for recursive calling of manage_after{Add|Clone}
00155         # and manage_beforeDelete. (bug #905677)
00156         populateFolder(self.folder, 'SimpleFolder', 'DDocument')
00157         d = self.folder.folder2.folder22.folder221.doc2211
00158         uid = UID(d)
00159         # Called afterAdd once
00160         self.assertEquals(ADD_COUNTER.get(uid), 1)
00161         # Never called beforeDelete or afterClone
00162         self.assertEquals(DELETE_COUNTER.get(uid), 0)
00163         self.assertEquals(CLONE_COUNTER.get(uid), 0)
00164 
00165         # make sure we have _p_jar
00166         transaction.savepoint(optimistic=True)
00167 
00168         d_count = self.getCounts(d)
00169 
00170         # Rename the parent folder
00171         self.folder.folder2.folder22.manage_renameObject('folder221',
00172                                                          'new_folder221')
00173         expected = (d_count[0]+1, d_count[1]+1, d_count[2]+0)
00174         got = self.getCounts(d)
00175         self.assertEquals(got, expected)
00176 
00177         # Update base count
00178         d_count = got
00179 
00180         # Rename the root folder
00181         self.folder.manage_renameObject('folder2', 'new_folder2')
00182 
00183         expected = (d_count[0]+1, d_count[1]+1, d_count[2]+0)
00184         got = self.getCounts(d)
00185         self.assertEquals(got, expected)
00186 
00187         # Update base count
00188         d_count = got
00189 
00190         # Copy the root folder
00191         cb = self.folder.manage_copyObjects(['new_folder2'])
00192         self.folder.manage_pasteObjects(cb)
00193 
00194         # Should *not* call manage_afterAdd or manage_afterClone,
00195         # or to manage_beforeDelete for the source object.
00196         expected = (d_count[0], d_count[1], d_count[2])
00197         got = self.getCounts(d)
00198         self.assertEquals(got, expected)
00199 
00200         new_d = self.folder.copy_of_new_folder2.folder22.new_folder221.doc2211
00201         got = self.getCounts(new_d)
00202         # Should have called manage_afterAdd and manage_afterClone for
00203         # the *new* object.
00204         self.assertEquals(got, (1, 0, 1))

Here is the call graph for this function:

Definition at line 125 of file test_rename.py.

00125 
00126     def test_rename(self):
00127         obj_id = 'demodoc'
00128         new_id = 'new_demodoc'
00129         doc = makeContent(self.folder, portal_type='Fact', id=obj_id)
00130         content = 'The book is on the table!'
00131         doc.setQuote(content, mimetype="text/plain")
00132         self.failUnless(str(doc.getQuote()) == str(content))
00133         # make sure we have _p_jar
00134         transaction.savepoint(optimistic=True)
00135         self.folder.manage_renameObject(obj_id, new_id)
00136         doc = getattr(self.folder, new_id)
00137         self.failUnless(str(doc.getQuote()) == str(content))
00138         uid = UID(doc)
00139         # Should call afterAdd twice, one for the object
00140         # creation and another for the rename
00141         self.assertEquals(ADD_COUNTER.get(uid), 2)
00142         # Should call beforeDelete once, when renaming the object
00143         self.assertEquals(DELETE_COUNTER.get(uid), 1)
00144         # Should never call afterClone
00145         self.assertEquals(CLONE_COUNTER.get(uid), 0)

Here is the call graph for this function:


The documentation for this class was generated from the following file: