source: products/quintagroup.referencedatagridfield/branches/plone4/quintagroup/referencedatagridfield/tests/base.py @ 2341

Last change on this file since 2341 was 2341, checked in by mylan, 14 years ago

Updated testing content creation

  • Property svn:eol-style set to native
File size: 2.3 KB
RevLine 
[2334]1import unittest
2
3#from zope.testing import doctestunit
4#from zope.component import testing
5from Products.Five import zcml
6from Products.Five import fiveconfigure
7from Testing import ZopeTestCase as ztc
[2339]8from AccessControl import getSecurityManager
9from AccessControl.SecurityManagement import setSecurityManager
[2334]10
11from Products.Archetypes.tests.utils import makeContent
12
13from Products.Five import fiveconfigure
14from Products.PloneTestCase import PloneTestCase as ptc
15from Products.PloneTestCase.layer import PloneSite
16
17# install site
18ptc.setupPloneSite(extension_profiles=[
19        'quintagroup.referencedatagridfield:default',
20        'quintagroup.referencedatagridfield:examples'
21        ])
22
23import quintagroup.referencedatagridfield
24
25class MixIn(object):
26    """ Mixin for setting up the necessary bits for testing the
27        quintagroup.referencedatagridfield
28    """
29
30    class layer(PloneSite):
31
32        @classmethod
33        def setUp(cls):
34            fiveconfigure.debug_mode = True
35            zcml.load_config('configure.zcml',
36                             quintagroup.referencedatagridfield)
[2336]37            ztc.installPackage('quintagroup.referencedatagridfield')
[2334]38            fiveconfigure.debug_mode = False
39
40        @classmethod
41        def tearDown(cls):
42            pass
43
[2341]44    def createDemo(self, wfaction=None):
[2336]45        # Create tested content
[2339]46        sm = getSecurityManager()
[2337]47        self.loginAsPortalOwner()
[2341]48        content = {
49            "demo": {"type":'ReferenceDataGridDemoType', "title": 'RDGF Demo'},
50            "doc": {"type":'Document', "title": 'Test Document'},
51            "doc2": {"type":'Document', "title": 'Test Document 2'},
52            }
[2339]53        try:
[2341]54            wf = self.portal.portal_workflow
55            for cid, data in content.items():
56                makeContent(self.portal, portal_type=data['type'], id=cid)
57                obj = getattr(self.portal, cid)
58                obj.setTitle(data['title'])
59                obj.reindexObject()
60                if wfaction:
61                    wf.doActionFor(obj, wfaction)
62                setattr(self, cid, obj)
[2339]63        finally:
64            setSecurityManager(sm)
[2336]65
[2334]66class TestCase(MixIn, ptc.PloneTestCase):
67    """ Base TestCase for quintagroup.referencedatagridfield """
[2341]68
69class FunctionalTestCase(MixIn, ptc.FunctionalTestCase):
70    """ Base TestCase for quintagroup.referencedatagridfield """
71
Note: See TracBrowser for help on using the repository browser.