Back to index

plone3  3.1.7
Public Member Functions | Public Attributes
CMFDiffTool.tests.testChangeSet.TestChangeSet Class Reference
Inheritance diagram for CMFDiffTool.tests.testChangeSet.TestChangeSet:
Inheritance graph
[legend]
Collaboration diagram for CMFDiffTool.tests.testChangeSet.TestChangeSet:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def afterSetUp
def testInterface
def setupTestObjects
def setupTestFolders
def testChangeSetUnchanged
def testChangeSetChanged
def testChangeSetFolderUnchanged
def testChangeSetFolderChanged
def testChangeSetFolderDocChanged
def testChangeSetFolderDocRemoved
def testChangeSetFolderDocAdded
def testChangeSetFolderReordered
def testChangeSetFolderComplex

Public Attributes

 p_diff
 cs

Detailed Description

Tests for ChangeSet objects

Definition at line 10 of file testChangeSet.py.


Member Function Documentation

Definition at line 13 of file testChangeSet.py.

00013 
00014     def afterSetUp(self):
00015         self.p_diff = self.portal.portal_diff
00016         cs = BaseChangeSet('my_changeset')
00017         # ChangeSet needs an acquisition wrapper
00018         self.cs = cs.__of__(self.portal)

Definition at line 31 of file testChangeSet.py.

00031 
00032     def setupTestFolders(self):
00033         self.folder.invokeFactory('Folder','folder1', title='My Folder Title')
00034         self.folder.folder1.invokeFactory('Document','doc1', title='My Title1')
00035         self.folder.folder1.invokeFactory('Document','doc2', title='My Title2')
00036         self.folder.folder1.invokeFactory('Document','doc3', title='My Title3')
00037         self.folder.manage_pasteObjects(
00038                                   self.folder.manage_copyObjects(['folder1']))
00039         self.portal.portal_diff.setDiffField('Document', 'Title', 'Field Diff')
00040         self.portal.portal_diff.setDiffField('Folder', 'title', 'Field Diff')

Here is the caller graph for this function:

Definition at line 25 of file testChangeSet.py.

00025 
00026     def setupTestObjects(self):
00027         self.folder.invokeFactory('Document','doc1', title='My Title')
00028         self.folder.manage_pasteObjects(
00029                                      self.folder.manage_copyObjects(['doc1']))
00030         self.portal.portal_diff.setDiffField('Document', 'Title', 'Field Diff')

Here is the caller graph for this function:

Definition at line 48 of file testChangeSet.py.

00048 
00049     def testChangeSetChanged(self):
00050         self.setupTestObjects()
00051         self.folder.copy_of_doc1.setTitle('My New Title')
00052         self.cs.computeDiff(self.folder.doc1, self.folder.copy_of_doc1)
00053         diffs = self.cs.getDiffs()
00054         self.assertEqual(len(diffs), 1)
00055         self.failIf(diffs[0].same)
00056         self.assertEqual(diffs[0].ndiff(), '- My Title\n+ My New Title')

Here is the call graph for this function:

Definition at line 71 of file testChangeSet.py.

00071 
00072     def testChangeSetFolderChanged(self):
00073         self.setupTestFolders()
00074         self.folder.copy_of_folder1.setTitle('My New Title')
00075         self.cs.computeDiff(self.folder.folder1, self.folder.copy_of_folder1)
00076         diffs = self.cs.getDiffs()
00077         self.assertEqual(len(diffs), 1)
00078         self.failIf(diffs[0].same)
00079         self.assertEqual(diffs[0].ndiff(), '- My Folder Title\n+ My New Title')
00080         self.failIf(self.cs._added)
00081         self.failIf(self.cs._removed)
00082         sub_cs = self.cs.getSubDiffs()
00083         self.assertEqual(len(sub_cs), 3)
00084         # The sub diffs should show no changes
00085         for i in range(len(sub_cs)):
00086             self.failUnless(isinstance(sub_cs[i], BaseChangeSet))
00087             sub_diffs = sub_cs[i].getDiffs()
00088             self.assertEqual(len(sub_diffs), 1)
00089             self.failUnless(sub_diffs[0].same)

Here is the call graph for this function:

Definition at line 177 of file testChangeSet.py.

00177 
00178     def testChangeSetFolderComplex(self):
00179         self.setupTestFolders()\
00180         # Add a new sub object
00181         self.folder.copy_of_folder1.invokeFactory('Document','doc4',
00182                                                          title='My Doc Title')
00183         # Delete a sub object
00184         self.folder.copy_of_folder1.manage_delObjects('doc2')
00185         # Change one object
00186         self.folder.copy_of_folder1.doc3.setTitle('My New Title')
00187         # Change the folder itself
00188         self.folder.copy_of_folder1.setTitle('My New Title')
00189         # Move the changed object
00190         if hasattr(aq_base(self.folder.copy_of_folder1),'moveObjectsToTop'):
00191             self.folder.copy_of_folder1.moveObjectsToTop(['doc3'])
00192         elif hasattr(aq_base(self.folder.copy_of_folder1),
00193                                                         'moveObjectsByDelta'):
00194             self.folder.copy_of_folder1.moveObjectsByDelta(['doc3'], -3)
00195         else:
00196             # We don't have an orderable folder give up
00197             return
00198 
00199         self.cs.computeDiff(self.folder.folder1, self.folder.copy_of_folder1)
00200         diffs = self.cs.getDiffs()
00201         self.assertEqual(len(diffs), 1)
00202         self.failIf(diffs[0].same)
00203         self.assertEqual(diffs[0].ndiff(), '- My Folder Title\n+ My New Title')
00204         self.assertEqual(list(self.cs._added), ['doc4'])
00205         self.assertEqual(list(self.cs._removed), ['doc2'])
00206         sub_cs = self.cs.getSubDiffs()
00207         # We only have two potentially changed objects
00208         self.assertEqual(len(sub_cs), 2)
00209         # The sub diffs should show no changes
00210         for i in range(len(sub_cs)):
00211             self.failUnless(isinstance(sub_cs[i], BaseChangeSet))
00212             sub_diffs = sub_cs[i].getDiffs()
00213             self.assertEqual(len(sub_diffs), 1)
00214             if sub_cs[i].getId() == 'doc3':
00215                 self.failIf(sub_diffs[0].same)
00216                 self.assertEqual(sub_diffs[0].ndiff(),
00217                                                 '- My Title3\n+ My New Title')
00218             else:
00219                 self.failUnless(sub_diffs[0].same)
00220         # XXX we need an explicit way of noting reorders
00221 

Here is the call graph for this function:

Definition at line 132 of file testChangeSet.py.

00132 
00133     def testChangeSetFolderDocAdded(self):
00134         self.setupTestFolders()
00135         self.folder.copy_of_folder1.invokeFactory('Document','doc4',
00136                                                          title='My Doc Title')
00137         self.cs.computeDiff(self.folder.folder1, self.folder.copy_of_folder1)
00138         diffs = self.cs.getDiffs()
00139         self.assertEqual(len(diffs), 1)
00140         self.failUnless(diffs[0].same)
00141         sub_cs = self.cs.getSubDiffs()
00142         self.assertEqual(len(sub_cs), 3)
00143         # The sub diffs should show no changes
00144         for i in range(len(sub_cs)):
00145             self.failUnless(isinstance(sub_cs[i], BaseChangeSet))
00146             sub_diffs = sub_cs[i].getDiffs()
00147             self.assertEqual(len(sub_diffs), 1)
00148             self.failUnless(sub_diffs[0].same)
00149         self.failIf(self.cs._removed)
00150         self.assertEqual(list(self.cs._added), ['doc4'])

Here is the call graph for this function:

Definition at line 90 of file testChangeSet.py.

00090 
00091     def testChangeSetFolderDocChanged(self):
00092         self.setupTestFolders()
00093         self.folder.copy_of_folder1.doc1.setTitle('My New Title')
00094         self.cs.computeDiff(self.folder.folder1, self.folder.copy_of_folder1)
00095         diffs = self.cs.getDiffs()
00096         self.assertEqual(len(diffs), 1)
00097         self.failUnless(diffs[0].same)
00098         self.failIf(self.cs._added)
00099         self.failIf(self.cs._removed)
00100         sub_cs = self.cs.getSubDiffs()
00101         self.assertEqual(len(sub_cs), 3)
00102         for i in range(len(sub_cs)):
00103             self.failUnless(isinstance(sub_cs[i], BaseChangeSet))
00104             sub_diffs = sub_cs[i].getDiffs()
00105             self.assertEqual(len(sub_diffs), 1)
00106             # doc1 has changed
00107             if sub_cs[i].getId() == 'doc1':
00108                 self.failIf(sub_diffs[0].same)
00109                 self.assertEqual(sub_diffs[0].ndiff(),
00110                                                 '- My Title1\n+ My New Title')
00111             else:
00112                 self.failUnless(sub_diffs[0].same)

Here is the call graph for this function:

Definition at line 113 of file testChangeSet.py.

00113 
00114     def testChangeSetFolderDocRemoved(self):
00115         self.setupTestFolders()
00116         self.folder.copy_of_folder1.manage_delObjects('doc1')
00117         self.cs.computeDiff(self.folder.folder1, self.folder.copy_of_folder1)
00118         diffs = self.cs.getDiffs()
00119         self.assertEqual(len(diffs), 1)
00120         self.failUnless(diffs[0].same)
00121         sub_cs = self.cs.getSubDiffs()
00122         # We only have two potentially changed objects
00123         self.assertEqual(len(sub_cs), 2)
00124         # The sub diffs should show no changes
00125         for i in range(len(sub_cs)):
00126             self.failUnless(isinstance(sub_cs[i], BaseChangeSet))
00127             sub_diffs = sub_cs[i].getDiffs()
00128             self.assertEqual(len(sub_diffs), 1)
00129             self.failUnless(sub_diffs[0].same)
00130         self.failIf(self.cs._added)
00131         self.assertEqual(list(self.cs._removed), ['doc1'])

Here is the call graph for this function:

Definition at line 151 of file testChangeSet.py.

00151 
00152     def testChangeSetFolderReordered(self):
00153         self.setupTestFolders()
00154         if hasattr(aq_base(self.folder.copy_of_folder1),'moveObjectsToTop'):
00155             self.folder.copy_of_folder1.moveObjectsToTop(['doc3'])
00156         elif hasattr(aq_base(self.folder.copy_of_folder1),
00157                                                         'moveObjectsByDelta'):
00158             self.folder.copy_of_folder1.moveObjectsByDelta(['doc3'], -3)
00159         else:
00160             # We don't have an orderable folder give up
00161             return
00162         self.cs.computeDiff(self.folder.folder1, self.folder.copy_of_folder1)
00163         diffs = self.cs.getDiffs()
00164         self.assertEqual(len(diffs), 1)
00165         self.failUnless(diffs[0].same)
00166         self.failIf(self.cs._added)
00167         self.failIf(self.cs._removed)
00168         sub_cs = self.cs.getSubDiffs()
00169         self.assertEqual(len(sub_cs), 3)
00170         # The sub diffs should show no changes
00171         for i in range(len(sub_cs)):
00172             self.failUnless(isinstance(sub_cs[i], BaseChangeSet))
00173             sub_diffs = sub_cs[i].getDiffs()
00174             self.assertEqual(len(sub_diffs), 1)
00175             self.failUnless(sub_diffs[0].same)
00176         # XXX we need an explicit way of noting reorders

Here is the call graph for this function:

Definition at line 57 of file testChangeSet.py.

00057 
00058     def testChangeSetFolderUnchanged(self):
00059         self.setupTestFolders()
00060         self.cs.computeDiff(self.folder.folder1, self.folder.copy_of_folder1)
00061         diffs = self.cs.getDiffs()
00062         self.assertEqual(len(diffs), 1)
00063         self.failUnless(diffs[0].same)
00064         sub_cs = self.cs.getSubDiffs()
00065         self.assertEqual(len(sub_cs), 3)
00066         for i in range(len(sub_cs)):
00067             self.failUnless(isinstance(sub_cs[i], BaseChangeSet))
00068             sub_diffs = sub_cs[i].getDiffs()
00069             self.assertEqual(len(sub_diffs), 1)
00070             self.failUnless(sub_cs[0].same)

Here is the call graph for this function:

Definition at line 41 of file testChangeSet.py.

00041 
00042     def testChangeSetUnchanged(self):
00043         self.setupTestObjects()
00044         self.cs.computeDiff(self.folder.doc1, self.folder.copy_of_doc1)
00045         diffs = self.cs.getDiffs()
00046         self.assertEqual(len(diffs), 1)
00047         self.failUnless(diffs[0].same)

Here is the call graph for this function:

Ensure that tool instances implement the portal_diff interface

Definition at line 19 of file testChangeSet.py.

00019 
00020     def testInterface(self):
00021         """Ensure that tool instances implement the portal_diff interface"""
00022         from Products.CMFDiffTool.interfaces.IChangeSet import IChangeSet
00023         self.failUnless(IChangeSet.isImplementedByInstancesOf(ChangeSet))
00024         self.failUnless(IChangeSet.isImplementedByInstancesOf(BaseChangeSet))


Member Data Documentation

Definition at line 17 of file testChangeSet.py.

Definition at line 14 of file testChangeSet.py.


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