[2096] | 1 | import re |
---|
[2097] | 2 | import string |
---|
[2096] | 3 | import unittest |
---|
| 4 | |
---|
| 5 | from Products.Five import zcml |
---|
| 6 | from Products.Five import fiveconfigure |
---|
| 7 | from Testing import ZopeTestCase as ztc |
---|
| 8 | from Products.PloneTestCase.layer import onsetup |
---|
| 9 | from Products.PloneTestCase import PloneTestCase as ptc |
---|
| 10 | |
---|
| 11 | PRODUCTS = [ |
---|
| 12 | 'Products.PloneFormGen', |
---|
| 13 | 'quintagroup.captcha.core', |
---|
| 14 | 'quintagroup.pfg.captcha', |
---|
| 15 | ] |
---|
| 16 | PROFILES = [p+':default' for p in PRODUCTS] |
---|
| 17 | |
---|
| 18 | @onsetup |
---|
| 19 | def 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 | |
---|
| 27 | setup_product() |
---|
| 28 | ptc.setupPloneSite(extension_profiles=PROFILES) |
---|
| 29 | |
---|
| 30 | |
---|
[2097] | 31 | class 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 | |
---|
[2096] | 71 | def test_suite(): |
---|
| 72 | suite = unittest.TestSuite() |
---|
[2097] | 73 | suite.addTest(unittest.makeSuite(TestInstallations)) |
---|
[2096] | 74 | return suite |
---|