1 | # |
---|
2 | # testSetup |
---|
3 | # |
---|
4 | |
---|
5 | from Products.CMFCore.utils import getToolByName |
---|
6 | |
---|
7 | from quintagroup.pingtool.config import PROJECTNAME |
---|
8 | from base import * |
---|
9 | from config import INSTALLED_TYPES, CONFIGLET |
---|
10 | |
---|
11 | class TestSetup(TestCase): |
---|
12 | |
---|
13 | def afterSetUp(self): |
---|
14 | self.loginAsPortalOwner() |
---|
15 | self.qi = getToolByName(self.portal, 'portal_quickinstaller', None) |
---|
16 | self.ttool = getToolByName(self.portal, 'portal_types', None) |
---|
17 | self.ptool = getToolByName(self.portal, 'portal_properties', None) |
---|
18 | self.ctool = getToolByName(self.portal, 'portal_controlpanel', None) |
---|
19 | |
---|
20 | def test_installed_uninstalled_products(self): |
---|
21 | # test that package are installed/uninstalled well |
---|
22 | self.assertNotEqual(self.qi.isProductInstalled(PROJECTNAME), False, '%s is already installed' % PROJECTNAME) |
---|
23 | |
---|
24 | self.qi.uninstallProducts([PROJECTNAME]) |
---|
25 | self.assertNotEqual(self.qi.isProductInstalled(PROJECTNAME), True, '%s is already installed' % PROJECTNAME) |
---|
26 | |
---|
27 | def test_tool_install_uninstall(self): |
---|
28 | # test that tool are installed/uninstalled well |
---|
29 | tname = 'portal_pingtool' |
---|
30 | t = getToolByName(self.portal, tname, None) |
---|
31 | self.assertNotEqual(t, False, 'Tool %s not found after installation' % tname) |
---|
32 | self.failUnless(t, t) |
---|
33 | self.failUnless(isinstance(t, PingTool.PingTool), t.__class__) |
---|
34 | self.failUnlessEqual(t.meta_type, 'PingTool') |
---|
35 | self.failUnlessEqual(t.getId(), tname) |
---|
36 | |
---|
37 | self.qi.uninstallProducts([PROJECTNAME]) |
---|
38 | self.assertNotEqual(self.qi.isProductInstalled(PROJECTNAME), True, '%s is already installed' % PROJECTNAME) |
---|
39 | |
---|
40 | t = getToolByName(self.portal, tname, None) |
---|
41 | self.assertNotEqual(t, True, 'Tool %s found after uninstallation' % tname) |
---|
42 | |
---|
43 | def test_install_uninstall_types(self): |
---|
44 | # test that types are installed/uninstalled well |
---|
45 | ttool = self.ttool |
---|
46 | tids = ttool.objectIds() |
---|
47 | for id in INSTALLED_TYPES: |
---|
48 | self.assertNotEqual(id in tids, False, 'Type %s not found after installation' % id) |
---|
49 | tinfo = ttool[id] |
---|
50 | self.failUnless(tinfo.product == PROJECTNAME, tinfo.product) |
---|
51 | |
---|
52 | self.qi.uninstallProducts([PROJECTNAME]) |
---|
53 | self.assertNotEqual(self.qi.isProductInstalled(PROJECTNAME), True, '%s is already installed' % PROJECTNAME) |
---|
54 | |
---|
55 | tids = ttool.objectIds() |
---|
56 | for id in INSTALLED_TYPES: |
---|
57 | self.assertNotEqual(id in tids, True, 'Type %s found after uninstallation' % id) |
---|
58 | |
---|
59 | def test_actions_install_uninstall(self): |
---|
60 | # test that actions are installed/uninstalled well |
---|
61 | action = 'ping' |
---|
62 | ttool = self.ttool |
---|
63 | portal_action = getToolByName(self.portal, 'portal_actions') |
---|
64 | object_buttons = portal_action.object_buttons |
---|
65 | pt_actions_ids = [a.id for a in object_buttons.listActions()] |
---|
66 | self.assertNotEqual(action in pt_actions_ids, False, 'Action for %s not found after installation' % action) |
---|
67 | |
---|
68 | self.qi.uninstallProducts([PROJECTNAME]) |
---|
69 | self.assertNotEqual(self.qi.isProductInstalled(PROJECTNAME), True, '%s is already installed' % PROJECTNAME) |
---|
70 | |
---|
71 | pt_actions_ids = [a.id for a in object_buttons.listActions()] |
---|
72 | self.assertNotEqual(action in pt_actions_ids, True, 'Action for %s found after uninstallation' % action) |
---|
73 | |
---|
74 | def test_configlet_install_uninstall(self): |
---|
75 | configTool = self.ctool |
---|
76 | self.assert_(CONFIGLET in [a.getId() for a in configTool.listActions()], 'Configlet not found') |
---|
77 | |
---|
78 | self.qi.uninstallProducts([PROJECTNAME]) |
---|
79 | self.assertNotEqual(self.qi.isProductInstalled(PROJECTNAME), True, '%s is already installed' % PROJECTNAME) |
---|
80 | |
---|
81 | self.assert_(not CONFIGLET in [a.getId() for a in configTool.listActions()], 'Configlet found after uninstallation') |
---|
82 | |
---|
83 | def test_suite(): |
---|
84 | from unittest import TestSuite, makeSuite |
---|
85 | suite = TestSuite() |
---|
86 | suite.addTest(makeSuite(TestSetup)) |
---|
87 | return suite |
---|