def test_returnedUidsAreDifferent(self): generator = UniqueIdGeneratorTool() uid1 = generator() uid2 = generator() self.failIfEqual(uid1, uid2) self.failIfEqual(uid1(), uid2()) self.failIfEqual(uid1(), None)
def setUp(self): from Products.CMFCore.CatalogTool import CatalogTool from Products.CMFCore.utils import registerToolInterface from Products.CMFUid.interfaces import IUniqueIdHandler from Products.CMFUid.UniqueIdAnnotationTool \ import UniqueIdAnnotationTool from Products.CMFUid.UniqueIdGeneratorTool \ import UniqueIdGeneratorTool SecurityTest.setUp(self) self.app._setObject('dummy', DummyContent(id='dummy')) self.app._setObject('dummy2', DummyContent(id='dummy2')) self.ctool = CatalogTool().__of__(self.app) self.uidhandler = self._makeOne() sm = getSiteManager() sm.registerUtility(self.ctool, ICatalogTool) registerToolInterface('portal_catalog', ICatalogTool) sm.registerUtility(self.uidhandler, IUniqueIdHandler) sm.registerUtility(UniqueIdAnnotationTool(), IUniqueIdAnnotationManagement) sm.registerUtility(UniqueIdGeneratorTool(), IUniqueIdGenerator) sm.registerUtility(provided=IPortalCatalogQueueProcessor, factory=PortalCatalogProcessor) # Make sure we have our indices/columns uid_name = self.uidhandler.UID_ATTRIBUTE_NAME self.ctool.addIndex(uid_name, 'FieldIndex') self.ctool.addColumn(uid_name)
def setUp(self): SecurityTest.setUp(self) self.root._setObject('portal_catalog', CatalogTool()) self.root._setObject('portal_uidgenerator', UniqueIdGeneratorTool()) self.root._setObject('portal_uidhandler', UniqueIdHandlerTool()) self.root._setObject('dummy', DummyContent(id='dummy')) self.uid_attr_name = self.root.portal_uidhandler._UID_ATTRIBUTE_NAME setupIndexes(self.root.portal_catalog, self.uid_attr_name)
def setUp(self): SecurityTest.setUp(self) self.root._setObject('portal_catalog', CatalogTool()) self.root._setObject('portal_uidgenerator', UniqueIdGeneratorTool()) self.root._setObject('portal_uidannotation', UniqueIdAnnotationTool()) self.root._setObject('portal_uidhandler', UniqueIdHandlerTool()) self.root._setObject('dummy', DummyContent(id='dummy')) removeUnnecessaryIndexes(self.root.portal_catalog)
def addDummyItemWithUid(remove_on_add=None, remove_on_clone=None): generator = UniqueIdGeneratorTool() item = DummyItem() setattr(item, UID_ATTRNAME, generator()) uid = getattr(item, UID_ATTRNAME) if remove_on_add is not None: uid.remove_on_add = remove_on_add if remove_on_clone is not None: uid.remove_on_clone = remove_on_clone uid.setId(UID_ATTRNAME) return item, uid
def setUp(self): from Products.CMFCore.CatalogTool import CatalogTool from Products.CMFUid.UniqueIdAnnotationTool \ import UniqueIdAnnotationTool from Products.CMFUid.UniqueIdGeneratorTool \ import UniqueIdGeneratorTool SecurityTest.setUp(self) self.root._setObject('portal_catalog', CatalogTool()) self.root._setObject('portal_uidgenerator', UniqueIdGeneratorTool()) self.root._setObject('portal_uidannotation', UniqueIdAnnotationTool()) self.root._setObject('portal_uidhandler', self._getTargetClass()()) self.root._setObject('dummy', DummyContent(id='dummy')) self.root._setObject('dummy2', DummyContent(id='dummy2'))
def setUp(self): from Products.CMFCore.CatalogTool import CatalogTool from Products.CMFUid.UniqueIdAnnotationTool \ import UniqueIdAnnotationTool from Products.CMFUid.UniqueIdGeneratorTool \ import UniqueIdGeneratorTool SecurityTest.setUp(self) self.root._setObject('portal_catalog', CatalogTool()) self.root._setObject('portal_uidgenerator', UniqueIdGeneratorTool()) self.root._setObject('portal_uidannotation', UniqueIdAnnotationTool()) self.root._setObject('portal_uidhandler', self._getTargetClass()()) self.root._setObject('dummy', DummyContent(id='dummy')) self.root._setObject('dummy2', DummyContent(id='dummy2')) sm = getSiteManager() sm.registerUtility(self.root.portal_catalog, ICatalogTool) sm.registerUtility( self.root.portal_uidannotation , IUniqueIdAnnotationManagement ) sm.registerUtility(self.root.portal_uidgenerator, IUniqueIdGenerator) sm.registerUtility(self.root.portal_uidhandler, IUniqueIdHandler)
def setUp(self): from Products.CMFCore.CatalogTool import CatalogTool from Products.CMFUid.UniqueIdAnnotationTool \ import UniqueIdAnnotationTool from Products.CMFUid.UniqueIdGeneratorTool \ import UniqueIdGeneratorTool SecurityTest.setUp(self) self.root._setObject('portal_catalog', CatalogTool()) self.root._setObject('portal_uidgenerator', UniqueIdGeneratorTool()) self.root._setObject('portal_uidannotation', UniqueIdAnnotationTool()) self.root._setObject('portal_uidhandler', self._getTargetClass()()) self.root._setObject('dummy', DummyContent(id='dummy')) self.root._setObject('dummy2', DummyContent(id='dummy2')) sm = getSiteManager() sm.registerUtility(self.root.portal_uidannotation, IUniqueIdAnnotationManagement) sm.registerUtility(self.root.portal_uidgenerator, IUniqueIdGenerator) # Make sure we have our indices/columns uid_name = self.root.portal_uidhandler.UID_ATTRIBUTE_NAME self.root.portal_catalog.addIndex(uid_name, 'FieldIndex') self.root.portal_catalog.addColumn(uid_name)
def setUp(self): SecurityTest.setUp(self) self.root._setObject('portal_uidgenerator', UniqueIdGeneratorTool())
def test_getIdOfUidObject(self): generator = UniqueIdGeneratorTool() uid1 = generator() uid1.setId('blah') self.assertEqual(uid1.getId(), 'blah')
def test_interface(self): generator = UniqueIdGeneratorTool() IUniqueIdGenerator.isImplementedBy(generator) IAnnotatedUniqueId.isImplementedBy(generator())