Back to index

plone3  3.1.7
Public Member Functions | Private Member Functions
CMFDefault.tests.test_DublinCore.DublinCoreTests Class Reference
Inheritance diagram for CMFDefault.tests.test_DublinCore.DublinCoreTests:
Inheritance graph
[legend]
Collaboration diagram for CMFDefault.tests.test_DublinCore.DublinCoreTests:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def tearDown
def test_z2interfaces
def test_z3interfaces
def test_notifyModified
def test_creators_methods
def test_creators_upgrade
def test_ceiling_parsable
def test_publisher_no_metadata_tool
def test_publisher_with_metadata_tool
def test_timezone_metadata
def test_Date_with_explicit_timezone
def test_CreationDate_with_explicit_timezone
def test_ModificationDate_with_explicit_timezone
def test_EffectiveDate_with_explicit_timezone
def test_ExpirationDate_with_explicit_timezone

Private Member Functions

def _makeDummyContent

Detailed Description

Definition at line 58 of file test_DublinCore.py.


Member Function Documentation

def CMFDefault.tests.test_DublinCore.DublinCoreTests._makeDummyContent (   self,
  id,
  args,
  kw 
) [private]

Definition at line 60 of file test_DublinCore.py.

00060 
00061     def _makeDummyContent(self, id, *args, **kw):
00062         from Products.CMFCore.PortalContent import PortalContent
00063         from Products.CMFDefault.DublinCore import DefaultDublinCoreImpl
00064 
00065         class DummyContent(PortalContent, DefaultDublinCoreImpl):
00066             pass
00067 
00068         return DummyContent(id, *args, **kw)

Here is the caller graph for this function:

Definition at line 69 of file test_DublinCore.py.

00069 
00070     def tearDown(self):
00071         cleanUp()
00072         SecurityTest.tearDown(self)

Here is the call graph for this function:

Definition at line 155 of file test_DublinCore.py.

00155 
00156     def test_ceiling_parsable(self):
00157         # Test that a None ceiling date will be parsable by a DateIndex
00158         site = DummySite('site').__of__(self.root)
00159         item = self._makeDummyContent('item').__of__(site)
00160         self.assertEqual(item.expiration_date, None)
00161         self.assert_(_DateIndexConvert(item.expires()))

Here is the call graph for this function:

Definition at line 211 of file test_DublinCore.py.

00211 
00212     def test_CreationDate_with_explicit_timezone(self):
00213         item = self._makeDummyContent('item')
00214         item.creation_date = DateTime('2007-01-01T12:00:00Z')
00215         self.assertEqual(item.CreationDate('US/Eastern'),
00216                          '2007-01-01 07:00:00')

Here is the call graph for this function:

Definition at line 112 of file test_DublinCore.py.

00112 
00113     def test_creators_methods(self):
00114         site = DummySite('site').__of__(self.root)
00115         acl_users = site._setObject( 'acl_users', DummyUserFolder() )
00116         site._setObject( 'portal_membership', MembershipTool() )
00117         newSecurityManager(None, acl_users.user_foo)
00118         item = self._makeDummyContent('item').__of__(site)
00119         self.assertEqual( item.listCreators(), () )
00120 
00121         item.addCreator()
00122         self.assertEqual( item.listCreators(), ('user_foo',) )
00123         newSecurityManager(None, acl_users.user_bar)
00124         item.addCreator()
00125         self.assertEqual( item.listCreators(), ('user_foo', 'user_bar') )
00126         item.addCreator()
00127         self.assertEqual( item.listCreators(), ('user_foo', 'user_bar') )
00128         item.addCreator('user_baz')
00129         self.assertEqual( item.listCreators(),
00130                           ('user_foo', 'user_bar', 'user_baz') )
00131         item.setCreators('user_bar')
00132         self.assertEqual( item.listCreators(), ('user_bar',) )
00133         item.setCreators( ('user_baz',) )
00134         self.assertEqual( item.listCreators(), ('user_baz',) )

Here is the call graph for this function:

Definition at line 135 of file test_DublinCore.py.

00135 
00136     def test_creators_upgrade(self):
00137         site = DummySite('site').__of__(self.root)
00138         acl_users = site._setObject( 'acl_users', DummyUserFolder() )
00139         site._setObject( 'portal_membership', MembershipTool() )
00140         newSecurityManager(None, acl_users.user_foo)
00141         item = self._makeDummyContent('item').__of__(site)
00142         item.manage_fixupOwnershipAfterAdd()
00143         # fake an old object < CMF 1.5 without creators
00144         delattr(item, 'creators')
00145         self.assertEqual(item.Creator(), 'user_foo')
00146         newSecurityManager(None, acl_users.user_bar)
00147         item.addCreator()
00148         self.assertEqual(item.Creator(), 'user_foo')
00149         self.assertEqual(item.listCreators(), ('user_foo', 'user_bar'))
00150         # or if added directly
00151         delattr(item, 'creators')
00152         item.addCreator()
00153         self.assertEqual(item.Creator(), 'user_foo')
00154         self.assertEqual(item.listCreators(), ('user_foo', 'user_bar'))

Here is the call graph for this function:

Definition at line 205 of file test_DublinCore.py.

00205 
00206     def test_Date_with_explicit_timezone(self):
00207         item = self._makeDummyContent('item')
00208         item.effective_date = DateTime('2007-01-01T12:00:00Z')
00209         self.assertEqual(item.Date('US/Eastern'),
00210                          '2007-01-01 07:00:00')

Here is the call graph for this function:

Definition at line 223 of file test_DublinCore.py.

00223 
00224     def test_EffectiveDate_with_explicit_timezone(self):
00225         item = self._makeDummyContent('item')
00226         item.effective_date = DateTime('2007-01-01T12:00:00Z')
00227         self.assertEqual(item.EffectiveDate('US/Eastern'),
00228                          '2007-01-01 07:00:00')

Here is the call graph for this function:

Definition at line 229 of file test_DublinCore.py.

00229 
00230     def test_ExpirationDate_with_explicit_timezone(self):
00231         item = self._makeDummyContent('item')
00232         item.expiration_date = DateTime('2007-01-01T12:00:00Z')
00233         self.assertEqual(item.ExpirationDate('US/Eastern'),
00234                          '2007-01-01 07:00:00')

Here is the call graph for this function:

Definition at line 217 of file test_DublinCore.py.

00217 
00218     def test_ModificationDate_with_explicit_timezone(self):
00219         item = self._makeDummyContent('item')
00220         item.modification_date = DateTime('2007-01-01T12:00:00Z')
00221         self.assertEqual(item.ModificationDate('US/Eastern'),
00222                          '2007-01-01 07:00:00')

Here is the call graph for this function:

Definition at line 98 of file test_DublinCore.py.

00098 
00099     def test_notifyModified(self):
00100         site = DummySite('site').__of__(self.root)
00101         acl_users = site._setObject( 'acl_users', DummyUserFolder() )
00102         site._setObject( 'portal_membership', MembershipTool() )
00103         newSecurityManager(None, acl_users.user_foo)
00104         item = self._makeDummyContent('item').__of__(site)
00105         self.assertEqual( item.listCreators(), () )
00106         item.setModificationDate(0)
00107         initial_date = item.ModificationDate()
00108 
00109         item.notifyModified()
00110         self.assertEqual( item.listCreators(), ('user_foo',) )
00111         self.assertNotEqual( item.ModificationDate(), initial_date )

Here is the call graph for this function:

Definition at line 162 of file test_DublinCore.py.

00162 
00163     def test_publisher_no_metadata_tool(self):
00164         site = DummySite('site').__of__(self.root)
00165         item = self._makeDummyContent('item').__of__(site)
00166         self.assertEqual(item.Publisher(), 'No publisher')

Here is the call graph for this function:

Definition at line 167 of file test_DublinCore.py.

00167 
00168     def test_publisher_with_metadata_tool(self):
00169         PUBLISHER = 'Some Publisher'
00170         site = DummySite('site').__of__(self.root)
00171         site.portal_metadata = DummyMetadataTool(publisher=PUBLISHER)
00172         item = self._makeDummyContent('item').__of__(site)
00173         self.assertEqual(item.Publisher(), PUBLISHER)

Here is the call graph for this function:

Definition at line 174 of file test_DublinCore.py.

00174 
00175     def test_timezone_metadata(self):
00176         # http://www.zope.org/Collectors/CMF/325
00177         # If an item's timestamp(s) are stored in another timezone,
00178         # e.g. 4 hours further away from UTC, the DC date methods
00179         # should still return it in the local timezone so that all
00180         # user-visible dates can be compared to each other by eye.
00181         site = DummySite('site').__of__(self.root)
00182         item = self._makeDummyContent('item').__of__(site)
00183         dates_and_methods = (
00184             ('modification_date', 'ModificationDate'),
00185             ('effective_date', 'EffectiveDate'),
00186             ('effective_date', 'Date'),
00187             ('expiration_date', 'ExpirationDate'),
00188             ('creation_date', 'CreationDate'))
00189         offset = 4  # arbitrary, any value should work.
00190         for datename, dc_methodname in dates_and_methods:
00191             orig = getattr(item, datename)
00192             # Some default to None, fix that.
00193             if orig is None:
00194                 orig = DateTime()
00195                 setattr(item, datename, orig)
00196             orig_DC = getattr(item, dc_methodname)()
00197             # Change the timezone of the date.
00198             local_offset = orig.tzoffset() % (3600*24)
00199             other_offset = (local_offset + offset) % 24
00200             otherzone = 'GMT+%d' % other_offset
00201             setattr(item, datename, orig.toZone(otherzone))
00202             # Finally, verify that display has not changed.
00203             new_DC = getattr(item, dc_methodname)()
00204             self.assertEqual(orig_DC, new_DC)

Here is the call graph for this function:

Definition at line 73 of file test_DublinCore.py.

00073 
00074     def test_z2interfaces(self):
00075         from Interface.Verify import verifyClass
00076         from Products.CMFCore.interfaces.DublinCore \
00077                 import CatalogableDublinCore as ICatalogableDublinCore
00078         from Products.CMFCore.interfaces.DublinCore \
00079                 import DublinCore as IDublinCore
00080         from Products.CMFCore.interfaces.DublinCore \
00081                 import MutableDublinCore as IMutableDublinCore
00082         from Products.CMFDefault.DublinCore import DefaultDublinCoreImpl
00083 
00084         verifyClass(ICatalogableDublinCore, DefaultDublinCoreImpl)
00085         verifyClass(IDublinCore, DefaultDublinCoreImpl)
00086         verifyClass(IMutableDublinCore, DefaultDublinCoreImpl)

Definition at line 87 of file test_DublinCore.py.

00087 
00088     def test_z3interfaces(self):
00089         from zope.interface.verify import verifyClass
00090         from Products.CMFCore.interfaces import ICatalogableDublinCore
00091         from Products.CMFCore.interfaces import IDublinCore
00092         from Products.CMFCore.interfaces import IMutableDublinCore
00093         from Products.CMFDefault.DublinCore import DefaultDublinCoreImpl
00094 
00095         verifyClass(ICatalogableDublinCore, DefaultDublinCoreImpl)
00096         verifyClass(IDublinCore, DefaultDublinCoreImpl)
00097         verifyClass(IMutableDublinCore, DefaultDublinCoreImpl)


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