[CMF-checkins] CVS: CMF/CMFDefault/tests - test_DublinCore.py:1.2.44.1

Yvo Schubbe schubbe at web.de
Fri Dec 19 09:37:06 EST 2003


Update of /cvs-repository/CMF/CMFDefault/tests
In directory cvs.zope.org:/tmp/cvs-serv6937/CMFDefault/tests

Modified Files:
      Tag: yuppie-collector025-branch
	test_DublinCore.py 
Log Message:
- added listCreators and listContributors to DublinCore interface
- implemented these methods in DefaultDublinCoreImpl
- added addCreator method to DefaultDublinCoreImpl and made it called by notifyModified
- updated DiscussionItem to use the new interface


=== CMF/CMFDefault/tests/test_DublinCore.py 1.2 => 1.2.44.1 ===
--- CMF/CMFDefault/tests/test_DublinCore.py:1.2	Mon Jan  6 16:06:47 2003
+++ CMF/CMFDefault/tests/test_DublinCore.py	Fri Dec 19 09:37:05 2003
@@ -1,16 +1,70 @@
-from unittest import TestCase, TestSuite, makeSuite, main
+from unittest import TestSuite, makeSuite, main
 
+import Testing
 import Zope
 try:
+    Zope.startup()
+except AttributeError:
+    # for Zope versions before 2.6.1
+    pass
+try:
     from Interface.Verify import verifyClass
 except ImportError:
     # for Zope versions before 2.6.0
     from Interface import verify_class_implementation as verifyClass
 
+from AccessControl.SecurityManagement import newSecurityManager
+
+from Products.CMFCore.PortalContent import PortalContent
+from Products.CMFCore.tests.base.dummy import DummySite
+from Products.CMFCore.tests.base.dummy import DummyUserFolder
+from Products.CMFCore.tests.base.testcase import SecurityTest
 from Products.CMFDefault.DublinCore import DefaultDublinCoreImpl
+from Products.CMFDefault.MembershipTool import MembershipTool
+
+
+class DummyContent(PortalContent, DefaultDublinCoreImpl):
+    pass
+
+
+class DublinCoreTests(SecurityTest):
+
+    def setUp(self):
+        SecurityTest.setUp(self)
+        self.site = DummySite('site').__of__(self.root)
+        self.site._setObject( 'portal_membership', MembershipTool() )
+
+    def _makeDummyContent(self, id, *args, **kw):
+        return self.site._setObject( id, DummyContent(id, *args, **kw) )
+
+    def test_notifyModified(self):
+        acl_users = self.site._setObject( 'acl_users', DummyUserFolder() )
+        newSecurityManager(None, acl_users.user_foo)
+        item = self._makeDummyContent('item')
+        self.assertEqual( item.listCreators(), () )
+        item.setModificationDate(0)
+        initial_date = item.ModificationDate()
+
+        item.notifyModified()
+        self.assertEqual( item.listCreators(), ('user_foo',) )
+        self.assertNotEqual( item.ModificationDate(), initial_date )
 
+    def test_creators_methods(self):
+        acl_users = self.site._setObject( 'acl_users', DummyUserFolder() )
+        newSecurityManager(None, acl_users.user_foo)
+        item = self._makeDummyContent('item')
+        self.assertEqual( item.listCreators(), () )
 
-class DublinCoreTests(TestCase):
+        item.addCreator()
+        self.assertEqual( item.listCreators(), ('user_foo',) )
+        newSecurityManager(None, acl_users.user_bar)
+        item.addCreator()
+        self.assertEqual( item.listCreators(), ('user_foo', 'user_bar') )
+        item.addCreator()
+        self.assertEqual( item.listCreators(), ('user_foo', 'user_bar') )
+        item.addCreator('user_baz')
+        self.assertEqual( item.listCreators(),
+                          ('user_foo', 'user_bar', 'user_baz') )
 
     def test_interface(self):
         from Products.CMFCore.interfaces.DublinCore \




More information about the CMF-checkins mailing list