[Checkins] SVN: zope.copypastemove/branches/icemac-lp620353/ fix for LP #620353
Michael Howitz
mh at gocept.com
Thu Aug 19 09:06:25 EDT 2010
Log message for revision 115799:
fix for LP #620353
Changed:
U zope.copypastemove/branches/icemac-lp620353/buildout.cfg
U zope.copypastemove/branches/icemac-lp620353/setup.py
A zope.copypastemove/branches/icemac-lp620353/src/zope/copypastemove/tests/test_metadata.py
-=-
Modified: zope.copypastemove/branches/icemac-lp620353/buildout.cfg
===================================================================
--- zope.copypastemove/branches/icemac-lp620353/buildout.cfg 2010-08-19 12:53:51 UTC (rev 115798)
+++ zope.copypastemove/branches/icemac-lp620353/buildout.cfg 2010-08-19 13:06:24 UTC (rev 115799)
@@ -1,5 +1,6 @@
[buildout]
-develop = .
+develop = .
+ ../zope.dublincore
parts = test
[test]
Modified: zope.copypastemove/branches/icemac-lp620353/setup.py
===================================================================
--- zope.copypastemove/branches/icemac-lp620353/setup.py 2010-08-19 12:53:51 UTC (rev 115798)
+++ zope.copypastemove/branches/icemac-lp620353/setup.py 2010-08-19 13:06:24 UTC (rev 115799)
@@ -47,6 +47,7 @@
test=['zope.principalannotation',
'zope.testing',
'zope.traversing',
+ 'zope.dublincore >= 3.8.0dev',
]),
install_requires=['setuptools',
'zope.annotation',
Added: zope.copypastemove/branches/icemac-lp620353/src/zope/copypastemove/tests/test_metadata.py
===================================================================
--- zope.copypastemove/branches/icemac-lp620353/src/zope/copypastemove/tests/test_metadata.py (rev 0)
+++ zope.copypastemove/branches/icemac-lp620353/src/zope/copypastemove/tests/test_metadata.py 2010-08-19 13:06:24 UTC (rev 115799)
@@ -0,0 +1,86 @@
+##############################################################################
+#
+# Copyright (c) 2010 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Object copier metadata tests"""
+
+import datetime
+import unittest
+import zope.annotation
+import zope.annotation.attribute
+import zope.component
+import zope.container.contained
+import zope.container.interfaces
+import zope.container.sample
+import zope.container.testing
+import zope.copypastemove
+import zope.dublincore.testing
+import zope.dublincore.timeannotators
+import zope.lifecycleevent.interfaces
+import zope.location.interfaces
+import zope.traversing.api
+
+
+class CopyCreationTimeTest(zope.container.testing.ContainerPlacefulSetup,
+ unittest.TestCase):
+
+ def setUp(self):
+ super(CopyCreationTimeTest, self).setUp()
+ # We need a folder hierarchy for copying:
+ self.buildFolders()
+ # We need the default zope.dublincore adapters:
+ zope.dublincore.testing.setUpDublinCore()
+ # And the created annotator for the ObjectCopiedEvent
+ zope.component.provideHandler(
+ zope.dublincore.timeannotators.CreatedAnnotator,
+ [zope.lifecycleevent.interfaces.IObjectCopiedEvent])
+ zope.component.provideHandler(
+ zope.dublincore.timeannotators.CreatedAnnotator,
+ [None, zope.lifecycleevent.interfaces.IObjectCopiedEvent])
+ # The metadata are stored in annotations on the container:
+ zope.interface.classImplements(
+ zope.container.sample.SampleContainer,
+ zope.annotation.IAttributeAnnotatable)
+ zope.component.provideAdapter(
+ zope.annotation.attribute.AttributeAnnotations)
+ # We need the dispatch the copied event to the sub locations:
+ zope.component.provideHandler(
+ zope.copypastemove.dispatchToSublocations,
+ [None, zope.lifecycleevent.interfaces.IObjectCopiedEvent])
+ zope.component.provideAdapter(
+ zope.container.contained.ContainerSublocations,
+ [zope.container.interfaces.IReadContainer],
+ zope.location.interfaces.ISublocations)
+
+ def test_copy(self):
+ from zope.dublincore.interfaces import IZopeDublinCore
+ from zope.traversing.api import traverse
+
+ # Neither the original folder nor one of its subfolders have a
+ # creation date as there was no event on creation:
+ folder = traverse(self.rootFolder, 'folder1')
+ self.assertTrue(IZopeDublinCore(folder).created is None)
+ subfolder = traverse(self.rootFolder, 'folder1/folder1_1')
+ self.assertTrue(IZopeDublinCore(subfolder).created is None)
+
+ # After copying the folder, it has a creation date:
+ copier = zope.copypastemove.ObjectCopier(folder)
+ copier.copyTo(self.rootFolder, 'folder-copy')
+ folder_copy = traverse(self.rootFolder, 'folder-copy')
+ self.assertTrue(isinstance(IZopeDublinCore(folder_copy).created,
+ datetime.datetime))
+
+ # The subfolder has a creation date, too:
+ subfolder_copy = traverse(self.rootFolder, 'folder-copy/folder1_1')
+ self.assertTrue(isinstance(IZopeDublinCore(subfolder_copy).created,
+ datetime.datetime))
+
Property changes on: zope.copypastemove/branches/icemac-lp620353/src/zope/copypastemove/tests/test_metadata.py
___________________________________________________________________
Added: svn:keywords
+ Id Rev Date
Added: svn:eol-style
+ native
More information about the checkins
mailing list