1 | import unittest |
---|
2 | import transaction |
---|
3 | from AccessControl.SecurityManagement import newSecurityManager, \ |
---|
4 | noSecurityManager |
---|
5 | from Testing import ZopeTestCase as ztc |
---|
6 | from Products.CMFCore.utils import getToolByName |
---|
7 | from Products.PloneTestCase.layer import PloneSiteLayer |
---|
8 | |
---|
9 | from quintagroup.ploneformgen.readonlystringfield.tests.base import \ |
---|
10 | ReadOnlyStringFieldTestCase |
---|
11 | |
---|
12 | |
---|
13 | class TestErase(ReadOnlyStringFieldTestCase): |
---|
14 | # we use here nested layer for not to make an impact on |
---|
15 | # the rest test cases, this test case check uninstall procedure |
---|
16 | # thus it has to uninstall package which will be required to |
---|
17 | # be installed for other test cases |
---|
18 | class layer(PloneSiteLayer): |
---|
19 | @classmethod |
---|
20 | def setUp(cls): |
---|
21 | app = ztc.app() |
---|
22 | portal = app.plone |
---|
23 | |
---|
24 | # elevate permissions |
---|
25 | user = portal.getWrappedOwner() |
---|
26 | newSecurityManager(None, user) |
---|
27 | |
---|
28 | tool = getToolByName(portal, 'portal_quickinstaller') |
---|
29 | product_name = 'quintagroup.ploneformgen.readonlystringfield' |
---|
30 | if tool.isProductInstalled(product_name): |
---|
31 | tool.uninstallProducts([product_name,]) |
---|
32 | |
---|
33 | # drop elevated perms |
---|
34 | noSecurityManager() |
---|
35 | |
---|
36 | transaction.commit() |
---|
37 | ztc.close(app) |
---|
38 | |
---|
39 | def afterSetUp(self): |
---|
40 | self.loginAsPortalOwner() |
---|
41 | |
---|
42 | def test_factoryTool(self): |
---|
43 | tool = getToolByName(self.portal, 'portal_factory') |
---|
44 | self.failIf('FormReadonlyStringField' in tool._factory_types.keys(), |
---|
45 | 'FormReadonlyStringField type is still in portal_factory tool.') |
---|
46 | |
---|
47 | def test_typesTool(self): |
---|
48 | tool = getToolByName(self.portal, 'portal_types') |
---|
49 | self.failIf('FormReadonlyStringField' in tool.objectIds(), |
---|
50 | 'FormReadonlyStringField type is still in portal_types tool.') |
---|
51 | |
---|
52 | def test_propertiesTool(self): |
---|
53 | tool = getToolByName(self.portal, 'portal_properties') |
---|
54 | navtree = tool.navtree_properties |
---|
55 | self.failIf('FormReadonlyStringField' in navtree.metaTypesNotToList, |
---|
56 | 'FormReadonlyStringField is still in metaTypesNotToList property.') |
---|
57 | site = tool.site_properties |
---|
58 | self.failIf('FormReadonlyStringField' in site.types_not_searched, |
---|
59 | 'FormReadonlyStringField is still in types_not_searched property.') |
---|
60 | |
---|
61 | def test_skinsTool(self): |
---|
62 | tool = getToolByName(self.portal, 'portal_skins') |
---|
63 | self.failIf('readonlystringfield' in tool.objectIds(), |
---|
64 | 'There is still readonlystringfield folder in portal_skins.') |
---|
65 | for path_id, path in tool._getSelections().items(): |
---|
66 | layers = [l.strip() for l in path.split(',')] |
---|
67 | self.failIf('readonlystringfield' in layers, |
---|
68 | 'readonlystringfield layer is still in %s.' % path_id) |
---|
69 | |
---|
70 | def test_suite(): |
---|
71 | suite = unittest.TestSuite() |
---|
72 | suite.addTest(unittest.makeSuite(TestErase)) |
---|
73 | return suite |
---|