vendor/Five/1.2b-r20590

view tests/test_event.py @ 0:3673ed425f80

Vendor import of Five 1.2b+ (r20590)
author fguillaume
date Fri, 02 Dec 2005 20:25:42 +0000
parents
children
line source
1 ##############################################################################
2 #
3 # Copyright (c) 2004, 2005 Zope Corporation and Contributors.
4 # All Rights Reserved.
5 #
6 # This software is subject to the provisions of the Zope Public License,
7 # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
8 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
9 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
10 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
11 # FOR A PARTICULAR PURPOSE.
12 #
13 ##############################################################################
14 """Test events triggered by Five
16 $Id: test_event.py 19706 2005-11-10 14:05:16Z efge $
17 """
18 import os, sys
19 if __name__ == '__main__':
20 execfile(os.path.join(sys.path[0], 'framework.py'))
23 # These classes aren't defined in the doctest because otherwise
24 # they wouldn't be picklable, and we need that to test copy/paste.
26 from OFS.SimpleItem import SimpleItem
27 from OFS.Folder import Folder
28 from OFS.OrderedFolder import OrderedFolder
29 from Products.BTreeFolder2.BTreeFolder2 import BTreeFolder2
31 class DontComplain(object):
32 def _verifyObjectPaste(self, object, validate_src=1):
33 pass
34 def cb_isMoveable(self):
35 return True
36 def cb_isCopyable(self):
37 return True
39 class NotifyBase(DontComplain):
40 def manage_afterAdd(self, item, container):
41 print 'old manage_afterAdd %s %s %s' % (self.getId(), item.getId(),
42 container.getId())
43 super(NotifyBase, self).manage_afterAdd(item, container)
44 manage_afterAdd.__five_method__ = True # Shut up deprecation warnings
45 def manage_beforeDelete(self, item, container):
46 super(NotifyBase, self).manage_beforeDelete(item, container)
47 print 'old manage_beforeDelete %s %s %s' % (self.getId(), item.getId(),
48 container.getId())
49 manage_beforeDelete.__five_method__ = True # Shut up deprecation warnings
50 def manage_afterClone(self, item):
51 print 'old manage_afterClone %s %s' % (self.getId(), item.getId())
52 super(NotifyBase, self).manage_afterClone(item)
53 manage_afterClone.__five_method__ = True # Shut up deprecation warnings
55 class MyApp(Folder):
56 def getPhysicalRoot(self):
57 return self
59 class MyFolder(NotifyBase, Folder):
60 pass
62 class MyOrderedFolder(NotifyBase, OrderedFolder):
63 pass
65 class MyBTreeFolder(NotifyBase, BTreeFolder2):
66 def _verifyObjectPaste(self, object, validate_src=1):
67 pass
69 class MyContent(NotifyBase, SimpleItem):
70 def __init__(self, id):
71 self._setId(id)
73 # These don't have manage_beforeDelete & co methods
75 class MyNewContent(DontComplain, SimpleItem):
76 def __init__(self, id):
77 self._setId(id)
79 class MyNewFolder(DontComplain, Folder):
80 pass
83 def test_suite():
84 from zope.testing.doctest import DocFileSuite
85 return DocFileSuite('event.txt', package="Products.Five.tests")
87 if __name__ == '__main__':
88 framework()