vendor/Five/1.2b-r20590

view browser/tests/test_pages.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 browser pages
16 $Id: test_pages.py 18860 2005-10-24 12:14:34Z philikon $
17 """
18 import os, sys
19 if __name__ == '__main__':
20 execfile(os.path.join(sys.path[0], 'framework.py'))
22 def test_ViewAcquisitionWrapping():
23 """
24 >>> import Products.Five.browser.tests
25 >>> from Products.Five import zcml
26 >>> zcml.load_config("configure.zcml", Products.Five)
27 >>> zcml.load_config('pages.zcml', package=Products.Five.browser.tests)
29 >>> from Products.Five.tests.testing.simplecontent import manage_addSimpleContent
30 >>> manage_addSimpleContent(self.folder, 'testoid', 'Testoid')
31 >>> uf = self.folder.acl_users
32 >>> uf._doAddUser('manager', 'r00t', ['Manager'], [])
33 >>> self.login('manager')
35 >>> view = self.folder.unrestrictedTraverse('testoid/eagle.txt')
36 >>> view is not None
37 True
38 >>> from Products.Five.browser.tests.pages import SimpleView
39 >>> isinstance(view, SimpleView)
40 True
41 >>> view()
42 'The eagle has landed'
44 This sucks, but we know it
46 >>> from Acquisition import aq_parent, aq_base
47 >>> aq_parent(view.context) is view
48 True
50 This is the right way to get the context parent
52 >>> view.context.aq_inner.aq_parent is not view
53 True
54 >>> view.context.aq_inner.aq_parent is self.folder
55 True
57 Clean up:
59 >>> from zope.app.tests.placelesssetup import tearDown
60 >>> tearDown()
61 """
63 def test_suite():
64 import unittest
65 from Testing.ZopeTestCase import installProduct, ZopeDocTestSuite
66 from Testing.ZopeTestCase import ZopeDocFileSuite
67 from Testing.ZopeTestCase import FunctionalDocFileSuite
68 installProduct('PythonScripts') # for Five.tests.testing.restricted
69 return unittest.TestSuite((
70 ZopeDocTestSuite(),
71 ZopeDocFileSuite('pages.txt', package='Products.Five.browser.tests'),
72 FunctionalDocFileSuite('pages_ftest.txt',
73 package='Products.Five.browser.tests')
74 ))
75 return suite
77 if __name__ == '__main__':
78 framework()