[CMF-checkins] CVS: Products/CMFDefault/tests -
test_DublinCore.py:1.2.26.1
Tres Seaver
tseaver at zope.com
Sun Aug 1 16:51:12 EDT 2004
Update of /cvs-repository/Products/CMFDefault/tests
In directory cvs.zope.org:/tmp/cvs-serv16902/CMFDefault/tests
Modified Files:
Tag: CMF-1_4-branch
test_DublinCore.py
Log Message:
- Use the 'portal_metadata' tool's 'getPublisher' for the DublinCore
'Publisher' element (thanks to Eric Brown for the patch).
=== Products/CMFDefault/tests/test_DublinCore.py 1.2 => 1.2.26.1 ===
--- Products/CMFDefault/tests/test_DublinCore.py:1.2 Mon Jan 6 16:06:47 2003
+++ Products/CMFDefault/tests/test_DublinCore.py Sun Aug 1 16:51:11 2004
@@ -1,16 +1,32 @@
-from unittest import TestCase, TestSuite, makeSuite, main
+import unittest
import Zope
+from Acquisition import Implicit
+
try:
from Interface.Verify import verifyClass
except ImportError:
# for Zope versions before 2.6.0
from Interface import verify_class_implementation as verifyClass
-from Products.CMFDefault.DublinCore import DefaultDublinCoreImpl
+from Products.CMFCore.tests.base.testcase import SecurityRequestTest
+
+class DublinCoreTests( SecurityRequestTest ):
+
+ def _makeSite( self ):
+ from OFS.Folder import Folder
+ site = Folder( 'site' )
+ self.root._setObject( 'site', site )
+ return self.root._getOb( 'site' )
+
+ def _makeDummyContent( self, **kw ):
+ from Products.CMFDefault.DublinCore import DefaultDublinCoreImpl
-class DublinCoreTests(TestCase):
+ class DummyContent( Implicit, DefaultDublinCoreImpl ):
+ pass
+
+ return DummyContent( **kw )
def test_interface(self):
from Products.CMFCore.interfaces.DublinCore \
@@ -19,16 +35,42 @@
import CatalogableDublinCore as ICatalogableDublinCore
from Products.CMFCore.interfaces.DublinCore \
import MutableDublinCore as IMutableDublinCore
+ from Products.CMFDefault.DublinCore import DefaultDublinCoreImpl
verifyClass(IDublinCore, DefaultDublinCoreImpl)
verifyClass(ICatalogableDublinCore, DefaultDublinCoreImpl)
verifyClass(IMutableDublinCore, DefaultDublinCoreImpl)
+ def test_publisher_no_metadata_tool( self ):
+
+ site = self._makeSite()
+ content = self._makeDummyContent().__of__( site )
+
+ self.assertEqual( content.Publisher(), 'No publisher' )
+
+ def test_publisher_with_metadata_tool( self ):
+
+ PUBLISHER = 'Some Publisher'
+
+ site = self._makeSite()
+ site.portal_metadata = DummyMetadataTool( publisher=PUBLISHER )
+ content = self._makeDummyContent().__of__( site )
+
+ self.assertEqual( content.Publisher(), PUBLISHER )
+
+class DummyMetadataTool( Implicit ):
+
+ def __init__( self, publisher ):
+ self._publisher = publisher
+
+ def getPublisher( self ):
+
+ return self._publisher
def test_suite():
- return TestSuite((
- makeSuite( DublinCoreTests ),
+ return unittest.TestSuite((
+ unittest.makeSuite( DublinCoreTests ),
))
if __name__ == '__main__':
- main(defaultTest='test_suite')
+ unittest.main(defaultTest='test_suite')
More information about the CMF-checkins
mailing list