vendor/Five/1.2b-r20590

view utilities/browser/tests/test_marker.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 """Unit tests for marker interface views.
16 $Id: test_marker.py 19218 2005-10-30 22:56:34Z yuppie $
17 """
18 import os, sys
19 if __name__ == '__main__':
20 execfile(os.path.join(sys.path[0], 'framework.py'))
22 def test_editview():
23 """
24 Set everything up:
26 >>> from zope.app.tests.placelesssetup import setUp, tearDown
27 >>> setUp()
28 >>> import Products.Five
29 >>> import Products.Five.utilities
30 >>> from Products.Five import zcml
31 >>> zcml.load_config('meta.zcml', Products.Five)
32 >>> zcml.load_config('permissions.zcml', Products.Five)
33 >>> zcml.load_config('configure.zcml', Products.Five.utilities)
34 >>> from Products.Five.utilities.browser.marker import EditView
35 >>> from Products.Five.tests.testing.simplecontent import SimpleContent
36 >>> obj = SimpleContent('foo', 'Foo').__of__(self.folder)
38 Create an EditView:
40 >>> view = EditView(obj, {})
41 >>> view.context.aq_inner is obj
42 True
43 >>> view.request
44 {}
45 >>> view.getAvailableInterfaceNames()
46 []
47 >>> view.getDirectlyProvidedNames()
48 []
49 >>> view.getInterfaceNames()
50 [...ISimpleContent...]
52 Try to add a marker interface that doesn't exist:
54 >>> view.update(('__builtin__.IFooMarker',), ())
55 Traceback (most recent call last):
56 ...
57 ComponentLookupError...
59 Now create the marker interface:
61 >>> from Products.Five.tests.testing.simplecontent import ISimpleContent
62 >>> class IFooMarker(ISimpleContent): pass
63 >>> from zope.app.component.interface import provideInterface
64 >>> provideInterface('', IFooMarker)
65 >>> view.getAvailableInterfaceNames()
66 [...IFooMarker...]
67 >>> view.getDirectlyProvidedNames()
68 []
70 And try again to add it to the object:
72 >>> view.update(('__builtin__.IFooMarker',), ())
73 >>> view.getAvailableInterfaceNames()
74 []
75 >>> view.getDirectlyProvidedNames()
76 [...IFooMarker...]
78 And remove it again:
80 >>> view.update((), ('__builtin__.IFooMarker',))
81 >>> view.getAvailableInterfaceNames()
82 [...IFooMarker...]
83 >>> view.getDirectlyProvidedNames()
84 []
86 Finally tear down:
88 >>> tearDown()
89 """
91 def test_suite():
92 from Testing.ZopeTestCase import ZopeDocTestSuite
93 return ZopeDocTestSuite()
95 if __name__ == '__main__':
96 framework()