[2334] | 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 |
---|
[2339] | 8 | from AccessControl import getSecurityManager |
---|
| 9 | from AccessControl.SecurityManagement import setSecurityManager |
---|
[2334] | 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) |
---|
[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] | 66 | class TestCase(MixIn, ptc.PloneTestCase): |
---|
| 67 | """ Base TestCase for quintagroup.referencedatagridfield """ |
---|
[2341] | 68 | |
---|
| 69 | class FunctionalTestCase(MixIn, ptc.FunctionalTestCase): |
---|
| 70 | """ Base TestCase for quintagroup.referencedatagridfield """ |
---|
| 71 | |
---|