[CMF-checkins] CVS: CMF/CMFUid/tests - test_uidgeneration.py:1.3
Grégoire Weber
zope.org at incept.ch
Tue Jul 20 21:37:02 EDT 2004
Update of /cvs-repository/CMF/CMFUid/tests
In directory cvs.zope.org:/tmp/cvs-serv6894/tests
Modified Files:
test_uidgeneration.py
Log Message:
- code cleanup, better namings
=== CMF/CMFUid/tests/test_uidgeneration.py 1.2 => 1.3 ===
--- CMF/CMFUid/tests/test_uidgeneration.py:1.2 Tue Jul 20 20:01:45 2004
+++ CMF/CMFUid/tests/test_uidgeneration.py Tue Jul 20 21:37:02 2004
@@ -30,13 +30,7 @@
from Products.CMFUid.UniqueIdGeneratorTool import UniqueIdGeneratorTool
-UID_ATTRNAME = 'uid'
-
-class DummyItem:
- def getUidObject(self):
- return getattr(self, UID_ATTRNAME)
- def setUid(self, uid):
- setattr(self, UID_ATTRNAME, uid)
+UID_ATTRNAME = 'cmf_uid'
class UniqueIdGeneratorTests(SecurityTest):
@@ -45,17 +39,13 @@
self.root._setObject('portal_uidgenerator', UniqueIdGeneratorTool())
self.root._setObject('dummy', DummyContent(id='dummy'))
- def addDummyContent(self, remove_on_add=None, remove_on_clone=None):
+ def attachUniqueId(self):
# attach a unique id to dummy content
dummy = self.root.dummy
generator = self.root.portal_uidgenerator
setattr(dummy, UID_ATTRNAME, generator())
uid = getattr(dummy, UID_ATTRNAME)
uid.setId(UID_ATTRNAME)
- if remove_on_add is not None:
- generator.remove_on_add = remove_on_add
- if remove_on_clone is not None:
- generator.remove_on_clone = remove_on_clone
return dummy, uid
def test_interface(self):
@@ -91,35 +81,38 @@
# obj.manage_afterClone(obj_at_target, obj_at_target)
def test_simulateItemAddRemovingUid(self):
- item, uid = self.addDummyContent()
+ item, uid = self.attachUniqueId()
uid.manage_afterAdd(item, None)
self.assertRaises(AttributeError, getattr, item, UID_ATTRNAME)
def test_simulateItemAddDoesNotTouchUid(self):
- item, uid = self.addDummyContent(remove_on_add=False)
+ item, uid = self.attachUniqueId()
+ self.root.portal_uidgenerator.remove_on_add = False
uid.manage_afterAdd(item, None)
self.assertEqual(getattr(item, UID_ATTRNAME)(), 1)
def test_simulateItemRename(self):
- item, uid = self.addDummyContent()
+ item, uid = self.attachUniqueId()
uid.manage_beforeDelete(item, None)
uid.manage_afterAdd(item, None)
self.assertEqual(getattr(item, UID_ATTRNAME)(), 1)
def test_simulateItemCloneRemovingUid1(self):
- item, uid = self.addDummyContent()
+ item, uid = self.attachUniqueId()
uid.manage_afterAdd(item, None)
uid.manage_afterClone(item)
self.assertRaises(AttributeError, getattr, item, UID_ATTRNAME)
def test_simulateItemCloneRemovingUid2(self):
- item, uid = self.addDummyContent(remove_on_add=False)
+ item, uid = self.attachUniqueId()
+ self.root.portal_uidgenerator.remove_on_add = False
uid.manage_afterAdd(item, None)
uid.manage_afterClone(item)
self.assertRaises(AttributeError, getattr, item, UID_ATTRNAME)
def test_simulateItemCloneDoesNotTouchUid(self):
- item, uid = self.addDummyContent(remove_on_clone=False)
+ item, uid = self.attachUniqueId()
+ self.root.portal_uidgenerator.remove_on_clone = False
uid.manage_afterAdd(item, None)
uid.manage_afterClone(item)
self.assertEqual(getattr(item, UID_ATTRNAME)(), 1)
More information about the CMF-checkins
mailing list