~ubuntu-branches/ubuntu/hardy/zope-resourceregistries/hardy

« back to all changes in this revision

Viewing changes to tests/five_tests_base.py

  • Committer: Bazaar Package Importer
  • Author(s): Fabio Tranchitella
  • Date: 2007-02-09 15:47:40 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20070209154740-xj4dvowhvxhhzrlm
Tags: 1.3.4-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
'''\
2
 
Set up tests with Five.
3
 
'''
4
 
 
5
 
import Products.ResourceRegistries.tests
6
 
import Products.Five
7
 
from Products.Five.zcml import load_string, load_config
8
 
 
9
 
try:
10
 
    from zope.app.testing import placelesssetup
11
 
    run_setUp = True
12
 
except ImportError:
13
 
    # Zope 2.8 / Five < 1.3
14
 
    from zope.app.tests import placelesssetup
15
 
    run_setUp = False
16
 
 
17
 
class FiveTestsBase:
18
 
    'Publishing with Five'
19
 
 
20
 
    def afterSetUp(self):
21
 
        if run_setUp:
22
 
            placelesssetup.setUp()
23
 
            # XXX I have absolutely no idea, why this fails on
24
 
            # Zope 2.8, however it seems to work fine without... ???
25
 
        # Allow traversing
26
 
        load_config('meta.zcml', package=Products.Five)
27
 
        load_config('configure.zcml', package=Products.Five)
28
 
        # Change to the context of this package
29
 
        Products.Five.zcml._context.package = Products.ResourceRegistries.tests
30
 
        load_string('''\
31
 
                    <configure xmlns="http://namespaces.zope.org/zope"
32
 
                           xmlns:five="http://namespaces.zope.org/five">
33
 
                    <include package="zope.app.traversing" />
34
 
                    <adapter
35
 
                          for="*"
36
 
                          factory="Products.Five.traversable.FiveTraversable"
37
 
                          provides="zope.app.traversing.interfaces.ITraversable"
38
 
                          />
39
 
                    <adapter
40
 
                          for="*"
41
 
                          factory="zope.app.traversing.adapters.Traverser"
42
 
                          provides="zope.app.traversing.interfaces.ITraverser"
43
 
                          />
44
 
                    </configure>''')
45
 
        # Enable Plone traversing
46
 
        load_string('''\
47
 
                    <configure xmlns="http://namespaces.zope.org/zope"
48
 
                           xmlns:five="http://namespaces.zope.org/five">
49
 
                      <!-- IPortal binds to the portal root -->
50
 
 
51
 
                      <interface
52
 
                          interface=".interfaces.IPortal"
53
 
                          type="zope.app.content.interfaces.IContentType"
54
 
                          />
55
 
 
56
 
                      <five:traversable class="Products.CMFPlone.Portal.PloneSite" />
57
 
 
58
 
                      <content class="Products.CMFPlone.Portal.PloneSite">
59
 
                        <implements
60
 
                            interface=".interfaces.IPortal"
61
 
                            />
62
 
                        <!--require
63
 
                            permission="zope.View"
64
 
                            interface=".interfaces.IPortal"
65
 
                            /-->
66
 
                      </content>
67
 
 
68
 
                      <!-- IPortalObject binds to all portal objects -->
69
 
                      
70
 
                      <interface
71
 
                          interface=".interfaces.IPortalObject"
72
 
                          type="zope.app.content.interfaces.IContentType"
73
 
                          />
74
 
                     
75
 
                      <five:implements
76
 
                          class="Products.CMFCore.PortalObject.PortalObjectBase"
77
 
                          interface=".interfaces.IPortalObject"
78
 
                          />
79
 
                      <five:implements
80
 
                          class="Products.Archetypes.public.BaseObject"
81
 
                          interface=".interfaces.IPortalObject"
82
 
                          />
83
 
                     
84
 
                      <five:traversable class="Products.CMFCore.PortalObject.PortalObjectBase" />
85
 
                      <five:traversable class="Products.Archetypes.public.BaseObject" />
86
 
 
87
 
                    </configure>''')
88
 
 
89
 
    def beforeTearDown(self):
90
 
        placelesssetup.tearDown()
91
 
        import Products.Five.zcml
92
 
        Products.Five.zcml._context = None