Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes | Private Member Functions
CMFUid.tests.test_uidannotation.UniqueIdAnnotationToolTests Class Reference
Inheritance diagram for CMFUid.tests.test_uidannotation.UniqueIdAnnotationToolTests:
Inheritance graph
[legend]
Collaboration diagram for CMFUid.tests.test_uidannotation.UniqueIdAnnotationToolTests:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def setUp
def test_z3interfaces
def test_setAndGetUid
def test_simulateItemAddAssigningUid
def test_simulateItemAddRemovingUid
def test_simulateItemAddAssignsNewUid
def test_simulateItemAddDoesNotTouchUid
def test_simulateItemRename
def test_simulateItemCloneRemovingUid1
def test_simulateItemCloneRemovingUid2
def test_simulateItemCloneDoesNotTouchUid
def test_simulateItemCloneAssignsNewUid
def test_simulateNestedFolderCloneRemovingUid1

Static Public Attributes

 layer = UidEventZCMLLayer

Private Member Functions

def _getTargetClass
def _initPolicyAndUser

Detailed Description

Definition at line 66 of file test_uidannotation.py.


Member Function Documentation

Definition at line 70 of file test_uidannotation.py.

00070 
00071     def _getTargetClass(self):
00072         from Products.CMFUid.UniqueIdAnnotationTool \
00073                 import UniqueIdAnnotationTool
00074 
00075         return UniqueIdAnnotationTool

def CMFUid.tests.test_uidannotation.UniqueIdAnnotationToolTests._initPolicyAndUser (   self,
  a_lambda = None,
  v_lambda = None,
  c_lambda = None 
) [private]

Definition at line 95 of file test_uidannotation.py.

00095 
00096                           ):
00097         from AccessControl import SecurityManager
00098 
00099         def _promiscuous( *args, **kw ):
00100             return 1
00101 
00102         if a_lambda is None:
00103             a_lambda = _promiscuous
00104 
00105         if v_lambda is None:
00106             v_lambda = _promiscuous
00107 
00108         if c_lambda is None:
00109             c_lambda = _promiscuous
00110 
00111         scp = _SensitiveSecurityPolicy( v_lambda, c_lambda )
00112         SecurityManager.setSecurityPolicy( scp )
00113         newSecurityManager( None
00114                           , _AllowedUser(a_lambda).__of__(self.app.acl_users))

Here is the caller graph for this function:

Definition at line 76 of file test_uidannotation.py.

00076 
00077     def setUp(self):
00078         SecurityTest.setUp(self)
00079         self.root._setObject('portal_uidannotation', self._getTargetClass()())
00080         self.root._setObject('portal_uidhandler', DummyUniqueIdHandlerTool())
00081 
00082         sm = getSiteManager()
00083         sm.registerUtility( self.root.portal_uidannotation
00084                           , IUniqueIdAnnotationManagement
00085                           )
00086 
00087         self.root._setObject('dummy', DummyContent(id='dummy'))
00088         self.root._setObject('site', SimpleFolder('site'))
00089 
00090         transaction.savepoint(optimistic=True)

Definition at line 125 of file test_uidannotation.py.

00125 
00126     def test_setAndGetUid(self):
00127         dummy = self.root.dummy
00128         annotation = self.root.portal_uidannotation(dummy, UID_ATTRNAME)
00129 
00130         self.assertEqual(annotation(), None)
00131         annotation.setUid(13)
00132         self.assertEqual(annotation(), 13)

Definition at line 146 of file test_uidannotation.py.

00146 
00147     def test_simulateItemAddAssigningUid(self):
00148         # an annotated object is set in place
00149         dummy = DummyContent(id='dummycontent')
00150         self.root.portal_uidannotation.assign_on_add = True
00151         self.root._setObject('dummycontent', dummy)
00152 
00153         annotation = getattr(dummy, UID_ATTRNAME, None)
00154 
00155         self.failUnless(annotation is not None)
    

Definition at line 164 of file test_uidannotation.py.

00164 
00165     def test_simulateItemAddAssignsNewUid(self):
00166         # an annotated object is set in place
00167         dummy = DummyContent(id='dummycontent')
00168         annotation = self.root.portal_uidannotation(dummy, UID_ATTRNAME)
00169         self.root.portal_uidannotation.assign_on_add = True
00170         self.root._setObject('dummycontent', dummy)
00171 
00172         self.failIf( getattr(dummy, UID_ATTRNAME)()==annotation() )

Definition at line 173 of file test_uidannotation.py.

00173 
00174     def test_simulateItemAddDoesNotTouchUid(self):
00175         # an annotated object is set in place
00176         dummy = DummyContent(id='dummycontent')
00177         annotation = self.root.portal_uidannotation(dummy, UID_ATTRNAME)
00178         self.root.portal_uidannotation.remove_on_add = False
00179         self.root._setObject('dummycontent', dummy)
00180 
00181         self.assertEqual(getattr(dummy, UID_ATTRNAME), annotation)

Definition at line 156 of file test_uidannotation.py.

00156 
00157     def test_simulateItemAddRemovingUid(self):
00158         # an annotated object is set in place
00159         dummy = DummyContent(id='dummycontent')
00160         annotation = self.root.portal_uidannotation(dummy, UID_ATTRNAME)
00161         self.root._setObject('dummycontent', dummy)
00162 
00163         self.assertRaises(AttributeError, getattr, dummy, UID_ATTRNAME)

Definition at line 244 of file test_uidannotation.py.

00244 
00245     def test_simulateItemCloneAssignsNewUid(self):
00246         # an object is set in place, annotated, and then copied
00247         self._initPolicyAndUser() # allow copy/paste operations
00248         dummy = TheClass('dummy')
00249         site = self.root.site
00250         site._setObject('dummy', dummy)
00251         annotation = self.root.portal_uidannotation(dummy, UID_ATTRNAME)
00252         self.root.portal_uidannotation.assign_on_clone = True
00253         self.root._setObject('folder1', SimpleFolder('folder1'))
00254 
00255         transaction.savepoint(optimistic=True)
00256         cookie = site.manage_copyObjects(ids=['dummy'])
00257         self.root.folder1.manage_pasteObjects( cookie )
00258         new_annotation = getattr(self.root.folder1.dummy, UID_ATTRNAME)
00259 
00260         self.failIf( annotation() == new_annotation() )

Here is the call graph for this function:

Definition at line 227 of file test_uidannotation.py.

00227 
00228     def test_simulateItemCloneDoesNotTouchUid(self):
00229         # an object is set in place, annotated, and then copied
00230         self._initPolicyAndUser() # allow copy/paste operations
00231         dummy = TheClass('dummy')
00232         site = self.root.site
00233         site._setObject('dummy', dummy)
00234         annotation = self.root.portal_uidannotation(dummy, UID_ATTRNAME)
00235         self.root.portal_uidannotation.remove_on_clone = False
00236         self.root._setObject('folder1', SimpleFolder('folder1'))
00237 
00238         transaction.savepoint(optimistic=True)
00239         cookie = site.manage_copyObjects(ids=['dummy'])
00240         self.root.folder1.manage_pasteObjects( cookie )
00241         new_annotation = getattr(self.root.folder1.dummy, UID_ATTRNAME)
00242 
00243         self.assertEqual(annotation(), new_annotation() )

Here is the call graph for this function:

Definition at line 196 of file test_uidannotation.py.

00196 
00197     def test_simulateItemCloneRemovingUid1(self):
00198         # an object is set in place, annotated and then copied
00199         self._initPolicyAndUser() # allow copy/paste operations
00200         dummy = TheClass('dummy')
00201         site = self.root.site
00202         site._setObject('dummy', dummy)
00203         annotation = self.root.portal_uidannotation(dummy, UID_ATTRNAME)
00204         self.root._setObject('folder1', SimpleFolder('folder1'))
00205 
00206         transaction.savepoint(optimistic=True)
00207         cookie = site.manage_copyObjects(ids=['dummy'])
00208         self.root.folder1.manage_pasteObjects( cookie )
00209 
00210         self.assertRaises(AttributeError, getattr, self.root.folder1.dummy, UID_ATTRNAME)

Here is the call graph for this function:

Definition at line 211 of file test_uidannotation.py.

00211 
00212     def test_simulateItemCloneRemovingUid2(self):
00213         # an object is set in place, annotated and then copied
00214         self._initPolicyAndUser() # allow copy/paste operations
00215         dummy = TheClass('dummy')
00216         site = self.root.site
00217         site._setObject('dummy', dummy)
00218         annotation = self.root.portal_uidannotation(dummy, UID_ATTRNAME)
00219         self.root.portal_uidannotation.remove_on_add = False
00220         self.root._setObject('folder1', SimpleFolder('folder1'))
00221 
00222         transaction.savepoint(optimistic=True)
00223         cookie = site.manage_copyObjects(ids=['dummy'])
00224         self.root.folder1.manage_pasteObjects( cookie )
00225 
00226         self.assertRaises(AttributeError, getattr, self.root.folder1.dummy, UID_ATTRNAME)

Here is the call graph for this function:

Definition at line 182 of file test_uidannotation.py.

00182 
00183     def test_simulateItemRename(self):
00184         # an object is set in place, annotated and then renamed
00185         self._initPolicyAndUser() # allow copy/paste operations
00186         dummy = TheClass('dummy')
00187         site = self.root.site
00188         site._setObject('dummy', dummy)
00189         annotation = self.root.portal_uidannotation(dummy, UID_ATTRNAME)
00190 
00191         transaction.savepoint(optimistic=True)
00192 
00193         site.manage_renameObject(id='dummy', new_id='dummy2')
00194         new_annotation = getattr(site.dummy2, UID_ATTRNAME)
00195         self.assertEqual(annotation(), new_annotation())

Here is the call graph for this function:

Definition at line 261 of file test_uidannotation.py.

00261 
00262     def test_simulateNestedFolderCloneRemovingUid1(self):
00263         self.root.site._setObject( 'foo', SimpleFolder(id='foo') )
00264         self.root.site._setObject( 'foo2', SimpleFolder(id='foo2') )
00265         foo = self.root.site.foo
00266         foo._setObject( 'sub1', SimpleFolder(id='sub1') )
00267         foo.sub1._setObject( 'sub2', SimpleFolder(id='sub2') )
00268         foo.sub1.sub2._setObject( 'baz', DummyContent(id='baz', catalog=1) )
00269         baz = foo.sub1.sub2.baz
00270         annotation = self.root.portal_uidannotation(baz, UID_ATTRNAME)
00271         self.assertEqual( getattr(baz, UID_ATTRNAME), annotation )
00272 
00273         transaction.savepoint(optimistic=True)
00274         cookie = self.root.site.manage_copyObjects(ids='foo')
00275         self.root.site.foo2.manage_pasteObjects(cookie)
00276 
00277         self.assertRaises(AttributeError, getattr, self.root.site.foo2.foo.sub1.sub2.baz, UID_ATTRNAME)
00278 

Definition at line 115 of file test_uidannotation.py.

00115 
00116     def test_z3interfaces(self):
00117         from zope.interface.verify import verifyClass
00118         from Products.CMFUid.interfaces import IUniqueIdAnnotation
00119         from Products.CMFUid.interfaces import IUniqueIdAnnotationManagement
00120         from Products.CMFUid.UniqueIdAnnotationTool \
00121                 import UniqueIdAnnotation
00122 
00123         verifyClass(IUniqueIdAnnotationManagement, self._getTargetClass())
00124         verifyClass(IUniqueIdAnnotation, UniqueIdAnnotation)


Member Data Documentation

Definition at line 68 of file test_uidannotation.py.


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