source: products/quintagroup.pfg.captcha/trunk/quintagroup/pfg/captcha/tests.py @ 2097

Last change on this file since 2097 was 2097, checked in by mylan, 14 years ago

#174: Added test for installation

  • Property svn:eol-style set to native
File size: 2.4 KB
Line 
1import re
2import string
3import unittest
4
5from Products.Five import zcml
6from Products.Five import fiveconfigure
7from Testing import ZopeTestCase as ztc
8from Products.PloneTestCase.layer import onsetup
9from Products.PloneTestCase import PloneTestCase as ptc
10
11PRODUCTS = [
12    'Products.PloneFormGen',
13    'quintagroup.captcha.core',
14    'quintagroup.pfg.captcha',
15]
16PROFILES = [p+':default' for p in PRODUCTS]
17
18@onsetup
19def setup_product():
20    fiveconfigure.debug_mode = True
21    import quintagroup.pfg.captcha
22    zcml.load_config('configure.zcml', quintagroup.pfg.captcha)
23    fiveconfigure.debug_mode = False
24    ztc.installPackage('quintagroup.pfg.captcha')
25    ztc.installPackage('quintagroup.captcha.core')
26
27setup_product()
28ptc.setupPloneSite(extension_profiles=PROFILES)
29
30
31class TestInstallations(ptc.PloneTestCase):
32
33    def testInstalledProducts(self):
34        qi = self.portal.portal_quickinstaller
35        installed = [p['id'] for p in qi.listInstalledProducts()]
36        for p in PRODUCTS:
37            if p.startswith('Products'):
38                p = p[9:]
39            self.assertEqual(p in installed, True,
40                '"%s" product not installed' % p)
41
42    def testType(self):
43        pt = self.portal.portal_types
44        self.assertEqual("CaptchaField" in pt.objectIds(), True)
45
46    def testPortalFactory(self):
47        pf = self.portal.portal_factory
48        self.assertEqual("CaptchaField" in pf.getFactoryTypes(), True)
49
50    def testWorkflow(self):
51        pw = self.portal.portal_workflow
52        default_chain = pw.getDefaultChain()
53        cf_chain = pw.getChainForPortalType('CaptchaField')
54        self.assertNotEqual(cf_chain == default_chain , True)
55
56    def testNotToList(self):
57        navtree = self.portal.portal_properties.navtree_properties
58        mtNotToList = navtree.getProperty("metaTypesNotToList")
59        self.assertEqual('CaptchaField' in mtNotToList, True)
60
61    def testSkins(self):
62        ps = self.portal.portal_skins
63        self.assertEqual("qplonecaptchafield" in ps.objectIds(), True)
64        for sname, spath in ps.getSkinPaths():
65            paths = filter(None, map(string.strip, spath.split(',')))
66            self.assertEqual("qplonecaptchafield" in paths, True,
67                '"qplonecaptchafield" layer not present in "%s" skin' % sname)
68
69           
70
71def test_suite():
72    suite = unittest.TestSuite()
73    suite.addTest(unittest.makeSuite(TestInstallations))
74    return suite
Note: See TracBrowser for help on using the repository browser.