[965] | 1 | import transaction |
---|
| 2 | |
---|
[832] | 3 | from Products.Five import zcml, fiveconfigure |
---|
| 4 | |
---|
| 5 | from Testing import ZopeTestCase as ztc |
---|
[965] | 6 | from AccessControl.SecurityManagement import newSecurityManager, \ |
---|
| 7 | noSecurityManager |
---|
[832] | 8 | |
---|
| 9 | from Products.PloneTestCase import PloneTestCase as ptc |
---|
[965] | 10 | from Products.PloneTestCase.layer import onsetup, PloneSiteLayer |
---|
[832] | 11 | from Products.CMFCore.utils import getToolByName |
---|
| 12 | |
---|
[880] | 13 | from config import PRODUCT |
---|
[832] | 14 | |
---|
[965] | 15 | |
---|
[832] | 16 | @onsetup |
---|
| 17 | def setup_product(): |
---|
| 18 | """Set up additional products and ZCML required to test this product. |
---|
| 19 | |
---|
| 20 | The @onsetup decorator causes the execution of this body to be deferred |
---|
| 21 | until the setup of the Plone site testing layer. |
---|
| 22 | """ |
---|
| 23 | |
---|
| 24 | # Load the ZCML configuration for this package and its dependencies |
---|
| 25 | |
---|
| 26 | fiveconfigure.debug_mode = True |
---|
| 27 | import quintagroup.plonecomments |
---|
| 28 | zcml.load_config('configure.zcml', quintagroup.plonecomments) |
---|
| 29 | zcml.load_config('overrides.zcml', quintagroup.plonecomments) |
---|
| 30 | fiveconfigure.debug_mode = False |
---|
| 31 | |
---|
| 32 | # We need to tell the testing framework that these products |
---|
| 33 | # should be available. This can't happen until after we have loaded |
---|
| 34 | # the ZCML. |
---|
| 35 | |
---|
| 36 | ztc.installPackage(PRODUCT) |
---|
| 37 | |
---|
| 38 | # The order here is important: We first call the deferred function and then |
---|
| 39 | # let PloneTestCase install it during Plone site setup |
---|
| 40 | |
---|
| 41 | setup_product() |
---|
| 42 | ptc.setupPloneSite(products=[PRODUCT]) |
---|
| 43 | |
---|
[965] | 44 | |
---|
[832] | 45 | class TestCase(ptc.PloneTestCase): |
---|
| 46 | """Base class used for test cases |
---|
| 47 | """ |
---|
| 48 | |
---|
[965] | 49 | |
---|
[832] | 50 | class FunctionalTestCase(ptc.FunctionalTestCase): |
---|
| 51 | """Test case class used for functional (doc-)tests |
---|
[965] | 52 | """ |
---|
| 53 | |
---|
| 54 | |
---|
| 55 | class TestErase(TestCase): |
---|
| 56 | # we use here nested layer for not to make an impact on |
---|
| 57 | # the rest test cases, this test case check uninstall procedure |
---|
| 58 | # thus it has to uninstall package which will be required to |
---|
| 59 | # be installed for other test cases |
---|
| 60 | class layer(PloneSiteLayer): |
---|
| 61 | @classmethod |
---|
| 62 | def setUp(cls): |
---|
| 63 | app = ztc.app() |
---|
| 64 | portal = app.plone |
---|
| 65 | |
---|
| 66 | # elevate permissions |
---|
| 67 | user = portal.getWrappedOwner() |
---|
| 68 | newSecurityManager(None, user) |
---|
| 69 | |
---|
| 70 | tool = getToolByName(portal, 'portal_quickinstaller') |
---|
| 71 | if tool.isProductInstalled(PRODUCT): |
---|
| 72 | tool.uninstallProducts([PRODUCT,]) |
---|
| 73 | |
---|
| 74 | # drop elevated perms |
---|
| 75 | noSecurityManager() |
---|
| 76 | |
---|
| 77 | transaction.commit() |
---|
| 78 | ztc.close(app) |
---|
| 79 | |
---|