/usr/lib/python2.7/dist-packages/zope/copypastemove/tests/test_metadata.py is in python-zope.copypastemove 4.0.0a1-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | ##############################################################################
#
# 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))
|