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

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

Fixed package installation, updated demo content creation to MixIn? class

  • Property svn:eol-style set to native
File size: 2.4 KB
Line 
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
8
9from Products.Archetypes.tests.utils import makeContent
10
11from Products.Five import fiveconfigure
12from Products.PloneTestCase import PloneTestCase as ptc
13from Products.PloneTestCase.layer import PloneSite
14
15# install site
16ptc.setupPloneSite(extension_profiles=[
17        'quintagroup.referencedatagridfield:default',
18        'quintagroup.referencedatagridfield:examples'
19        ])
20
21import quintagroup.referencedatagridfield
22
23class MixIn(object):
24    """ Mixin for setting up the necessary bits for testing the
25        quintagroup.referencedatagridfield
26    """
27
28    class layer(PloneSite):
29
30        @classmethod
31        def setUp(cls):
32            fiveconfigure.debug_mode = True
33            zcml.load_config('configure.zcml',
34                             quintagroup.referencedatagridfield)
35            ztc.installPackage('quintagroup.referencedatagridfield')
36            fiveconfigure.debug_mode = False
37
38        @classmethod
39        def tearDown(cls):
40            pass
41
42    def createDemo(self):
43        # Create tested content
44        if 'demo' not in self.portal.objectIds():
45            self.loginAsPortalOwner()
46            makeContent(self.portal, portal_type='ReferenceDataGridDemoType', id='demo')
47            self.demo = self.portal.demo
48            self.demo.setTitle('Reference DataGrid Field Demo')
49            self.demo.reindexObject()
50            self.logout()
51
52    # def createDefaultStructure(self):
53    #     if 'layer1' not in self.portal.objectIds():
54    #         self.setRoles(['Manager'])
55    #         makeContent(self.portal, portal_type='Folder', id='layer1')
56    #         self.portal.layer1.setTitle('Layer1')
57    #         self.portal.layer1.reindexObject()
58    #         makeContent(self.portal.layer1, portal_type='Folder', id='layer2')
59    #         self.folder = self.portal.layer1.layer2
60    #         self.folder.setTitle('Layer2')
61    #         self.folder.reindexObject()
62    #         self.setRoles(['Member'])
63    #     return self.portal.layer1.layer2
64
65    # def removeDefaultStructure(self):
66    #     if 'layer1' in self.portal.objectIds():
67    #         self.portal._delObject('layer1')
68
69
70class TestCase(MixIn, ptc.PloneTestCase):
71    """ Base TestCase for quintagroup.referencedatagridfield """
Note: See TracBrowser for help on using the repository browser.