vendor/Five/1.2b-r20590

view browser/tests/test_defaultview.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 Default View functionality
16 $Id: test_defaultview.py 17853 2005-09-25 13:34:25Z tseaver $
17 """
18 import os, sys
19 if __name__ == '__main__':
20 execfile(os.path.join(sys.path[0], 'framework.py'))
22 def test_default_view():
23 """
24 Test default view functionality
26 Let's register a couple of default views and make our stub classes
27 default viewable:
29 >>> import Products.Five.browser.tests
30 >>> from Products.Five import zcml
31 >>> zcml.load_config("configure.zcml", Products.Five)
32 >>> zcml.load_config('defaultview.zcml', Products.Five.browser.tests)
34 Now let's add a couple of stub objects:
36 >>> from Products.Five.tests.testing.simplecontent import manage_addSimpleContent
37 >>> from Products.Five.tests.testing.simplecontent import manage_addCallableSimpleContent
38 >>> from Products.Five.tests.testing.simplecontent import manage_addIndexSimpleContent
40 >>> manage_addSimpleContent(self.folder, 'testoid', 'Testoid')
41 >>> manage_addCallableSimpleContent(self.folder, 'testcall', 'TestCall')
42 >>> manage_addIndexSimpleContent(self.folder, 'testindex', 'TestIndex')
44 As a last act of preparation, we create a manager login:
46 >>> uf = self.folder.acl_users
47 >>> uf._doAddUser('manager', 'r00t', ['Manager'], [])
49 Test a simple default view:
51 >>> print http(r'''
52 ... GET /test_folder_1_/testoid HTTP/1.1
53 ... Authorization: Basic manager:r00t
54 ... ''')
55 HTTP/1.1 200 OK
56 ...
57 The eagle has landed
59 This tests whether an existing ``index_html`` method is still
60 supported and called:
62 >>> print http(r'''
63 ... GET /test_folder_1_/testindex HTTP/1.1
64 ... ''')
65 HTTP/1.1 200 OK
66 ...
67 Default index_html called
69 Disabled __call__ overriding for now. Causese more trouble than it
70 fixes. Thus, no test here:
72 #>>> print http(r'''
73 #... GET /test_folder_1_/testcall HTTP/1.1
74 #... ''')
75 #HTTP/1.1 200 OK
76 #...
77 #Default __call__ called
80 Clean up:
82 >>> from zope.app.tests.placelesssetup import tearDown
83 >>> tearDown()
84 """
86 def test_suite():
87 from Testing.ZopeTestCase import FunctionalDocTestSuite
88 return FunctionalDocTestSuite()
90 if __name__ == '__main__':
91 framework()