[205] | 1 | # |
---|
| 2 | # Register skins |
---|
| 3 | # |
---|
| 4 | |
---|
| 5 | import os, sys |
---|
| 6 | if __name__ == '__main__': |
---|
| 7 | execfile(os.path.join(sys.path[0], 'framework.py')) |
---|
| 8 | |
---|
| 9 | from base import * |
---|
| 10 | from config import skins_content, istalled_types, types_actions |
---|
| 11 | |
---|
| 12 | class TestSetup(TestCase): |
---|
| 13 | |
---|
| 14 | def afterSetUp(self): |
---|
| 15 | self.loginAsPortalOwner() |
---|
| 16 | self.qi = getattr(self.portal.aq_explicit, 'portal_quickinstaller') |
---|
| 17 | self.ttool = getattr(self.portal.aq_explicit, 'portal_types') |
---|
| 18 | self.ptool = getattr(self.portal.aq_explicit, 'portal_properties') |
---|
| 19 | |
---|
| 20 | def test_installed_products(self): |
---|
| 21 | qi = self.qi |
---|
| 22 | installed = [ prod['id'] for prod in qi.listInstalledProducts() ] |
---|
| 23 | self.failUnless('qPingTool' in installed, installed) |
---|
| 24 | self.failUnless('SimpleBlog' in installed, installed) |
---|
| 25 | |
---|
| 26 | def test_tool_installed(self): |
---|
| 27 | t = getToolByName(self.portal, 'portal_pingtool', None) |
---|
| 28 | self.failUnless(t, t) |
---|
| 29 | self.failUnless(isinstance(t, PingTool.PingTool), t.__class__) |
---|
| 30 | self.failUnlessEqual(t.meta_type, 'PingTool') |
---|
| 31 | self.failUnlessEqual(t.getId(), 'portal_pingtool') |
---|
| 32 | |
---|
| 33 | def test_skin_installed(self): |
---|
| 34 | stool = getattr(self.portal.aq_explicit, 'portal_skins') |
---|
| 35 | ids = stool.objectIds() |
---|
| 36 | self.failUnless('qpingtool' in ids, ids) |
---|
| 37 | content = [i.id for i in self.portal.portal_skins.qpingtool.objectValues()] |
---|
| 38 | content.sort() |
---|
| 39 | skins_content.sort() |
---|
| 40 | self.failUnless(content==skins_content) |
---|
| 41 | |
---|
| 42 | def test_installedAllTypes(self): |
---|
| 43 | # test that all types are installed well |
---|
| 44 | ttool = self.ttool |
---|
| 45 | tids = ttool.objectIds() |
---|
| 46 | for id in istalled_types: |
---|
| 47 | self.failUnless(id in tids, (id, tids)) |
---|
| 48 | tinfo = ttool[id] |
---|
| 49 | self.failUnless(tinfo.product == 'qPingTool', tinfo.product) |
---|
| 50 | |
---|
| 51 | def test_added_action(self): |
---|
| 52 | t = getToolByName(self.portal, 'portal_pingtool', None) |
---|
| 53 | ttool = self.ttool |
---|
| 54 | for type_actions in types_actions: |
---|
| 55 | pttool = ttool[type_actions['type']] |
---|
| 56 | for id, name, action, permission, category, visible in type_actions['actions']: |
---|
| 57 | pt_actions_ids = [a.getId() for a in pttool.listActions()] |
---|
| 58 | pt_action = [a for a in pttool.listActions() if a.id == id][0] |
---|
| 59 | self.failUnless(id in pt_actions_ids, pt_actions_ids) |
---|
| 60 | self.failUnless(name == pt_action.Title(), pt_action) |
---|
| 61 | self.failUnless(action == pt_action.getActionExpression(), pt_action) |
---|
| 62 | self.failUnless(permission == pt_action.getPermissions(), pt_action) |
---|
| 63 | self.failUnless(category == pt_action.getCategory(), pt_action) |
---|
| 64 | self.failUnless(visible == pt_action.getVisibility(), pt_action) |
---|
| 65 | |
---|
| 66 | |
---|
| 67 | def test_suite(): |
---|
| 68 | from unittest import TestSuite, makeSuite |
---|
| 69 | suite = TestSuite() |
---|
| 70 | suite.addTest(makeSuite(TestSetup)) |
---|
| 71 | return suite |
---|
| 72 | |
---|
| 73 | if __name__ == '__main__': |
---|
| 74 | framework() |
---|