1 | import unittest |
---|
2 | |
---|
3 | #from zope.testing import doctestunit |
---|
4 | #from zope.component import testing |
---|
5 | from Products.Five import zcml |
---|
6 | from Products.Five import fiveconfigure |
---|
7 | from Testing import ZopeTestCase as ztc |
---|
8 | from AccessControl import getSecurityManager |
---|
9 | from AccessControl.SecurityManagement import setSecurityManager |
---|
10 | |
---|
11 | from Products.Archetypes.tests.utils import makeContent |
---|
12 | |
---|
13 | from Products.Five import fiveconfigure |
---|
14 | from Products.PloneTestCase import PloneTestCase as ptc |
---|
15 | from Products.PloneTestCase.layer import PloneSite |
---|
16 | |
---|
17 | # install site |
---|
18 | ptc.setupPloneSite(extension_profiles=[ |
---|
19 | 'quintagroup.referencedatagridfield:default', |
---|
20 | 'quintagroup.referencedatagridfield:examples' |
---|
21 | ]) |
---|
22 | |
---|
23 | import quintagroup.referencedatagridfield |
---|
24 | |
---|
25 | class 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) |
---|
37 | ztc.installPackage('quintagroup.referencedatagridfield') |
---|
38 | fiveconfigure.debug_mode = False |
---|
39 | |
---|
40 | @classmethod |
---|
41 | def tearDown(cls): |
---|
42 | pass |
---|
43 | |
---|
44 | def createDemo(self): |
---|
45 | # Create tested content |
---|
46 | sm = getSecurityManager() |
---|
47 | self.loginAsPortalOwner() |
---|
48 | try: |
---|
49 | if not 'demo' in self.portal.objectIds(): |
---|
50 | makeContent(self.portal, portal_type='ReferenceDataGridDemoType', id='demo') |
---|
51 | self.demo = self.portal.demo |
---|
52 | self.demo.setTitle('Reference DataGrid Field Demo') |
---|
53 | self.demo.reindexObject() |
---|
54 | if not 'doc' in self.portal.objectIds(): |
---|
55 | makeContent(self.portal, portal_type='Document', id='doc') |
---|
56 | self.doc = self.portal.doc |
---|
57 | self.doc.setTitle('Test Document') |
---|
58 | self.doc.reindexObject() |
---|
59 | finally: |
---|
60 | setSecurityManager(sm) |
---|
61 | |
---|
62 | class TestCase(MixIn, ptc.PloneTestCase): |
---|
63 | """ Base TestCase for quintagroup.referencedatagridfield """ |
---|