source: products/quintagroup.captcha.core/trunk/quintagroup/captcha/core/tests/testInstallation.py @ 3128

Last change on this file since 3128 was 3128, checked in by vmaksymiv, 13 years ago

pep8 fixes

  • Property svn:eol-style set to native
File size: 3.8 KB
Line 
1from base import *
2
3
4class TestInstallation(ptc.FunctionalTestCase):
5
6    def afterSetUp(self):
7        self.loginAsPortalOwner()
8        self.qi = getToolByName(self.portal, 'portal_quickinstaller', None)
9        self.cp = getToolByName(self.portal, 'portal_controlpanel', None)
10        self.st = getToolByName(self.portal, 'portal_skins', None)
11        self.qi.installProduct(PRODUCT_NAME)
12
13    def getLayers(self):
14        return LAYERS + [LAYER_STATIC_CAPTCHAS]
15
16    def testPropertysheetInstall(self):
17        pp = getToolByName(self.portal, 'portal_properties')
18        msg = 'Property sheet isn\'t found'
19        self.assert_(PROPERTY_SHEET in pp.objectIds(), msg)
20
21    def testPropertysheetUninstall(self):
22        self.qi.uninstallProducts([PRODUCT_NAME])
23        pp = getToolByName(self.portal, 'portal_properties')
24        self.assert_(not PROPERTY_SHEET in pp.objectIds(),
25            'Property sheet found after uninstallation')
26
27    def testConfigletInstall(self):
28        list_ids = []
29        for action in self.cp.listActions():
30            list_ids.append(action.getId())
31        self.assert_(CONFIGLET_ID in list_ids, 'Configlet not found')
32
33    def testConfigletUninstall(self):
34        self.qi.uninstallProducts([PRODUCT_NAME])
35        self.assertNotEqual(self.qi.isProductInstalled(PRODUCT_NAME), True,
36                            '%s is already installed' % PRODUCT_NAME)
37        list_ids = []
38        for action in self.cp.listActions():
39            list_ids.append(action.getId())
40        msg = 'Configlet found after uninstallation'
41        self.assert_(not CONFIGLET_ID in list_ids, msg)
42
43    def testSkinsInstall(self):
44        skinstool = self.st
45        layers = self.getLayers()
46        for skin in skinstool.getSkinSelections():
47            path = skinstool.getSkinPath(skin)
48            path = map(str.strip, path.split(','))
49            for layer in layers:
50                msg = '%s directory view not found in'\
51                      'portal_skins after installation' % layer
52                self.assert_(layer.split('/')[0] in skinstool.objectIds(), msg)
53                msg = '%s layer not found in %s' % (PRODUCT_NAME, skin)
54                self.assert_(layer in path, msg)
55
56    def testSkinsUninstall(self):
57        self.qi.uninstallProducts([PRODUCT_NAME])
58        self.assertNotEqual(self.qi.isProductInstalled(PRODUCT_NAME), True,
59                            '%s is already installed' % PRODUCT_NAME)
60        skinstool = self.st
61        layers = self.getLayers()
62        for skin in skinstool.getSkinSelections():
63            path = skinstool.getSkinPath(skin)
64            path = map(str.strip, path.split(','))
65            for layer in layers:
66                msg = '%s directory view found in'\
67                      'portal_skins after uninstallation' % layer
68                skins_tool_ids = skinstool.objectIds()
69                self.assert_(not layer.split('/')[0] in skins_tool_ids, msg)
70                msg = '%s layer found in'\
71                      '%s after uninstallation' % (layer, skin)
72                self.assert_(not layer in path, msg)
73
74    def testToolInstall(self):
75        self.assert_(TOOL_ID in self.portal.objectIds())
76
77    def testToolUninstall(self):
78        self.qi.uninstallProducts([PRODUCT_NAME])
79        self.assertNotEqual(self.qi.isProductInstalled(PRODUCT_NAME), True,
80            '%s is already installed' % PRODUCT_NAME)
81        self.assert_(not TOOL_ID in self.portal.objectIds())
82
83    def testCaptchaKey(self):
84        ck = getattr(self.portal, CAPTCHA_KEY)
85        self.assert_(ck)
86        self.assertEqual(len(ck), 8)
87        self.qi.uninstallProducts([PRODUCT_NAME])
88        self.assert_(not self.portal.hasProperty(CAPTCHA_KEY))
89
90
91def test_suite():
92    suite = unittest.TestSuite()
93    suite.addTest(unittest.makeSuite(TestInstallation))
94    return suite
Note: See TracBrowser for help on using the repository browser.