[1] | 1 | |
---|
| 2 | import os, sys |
---|
| 3 | if __name__ == '__main__': |
---|
| 4 | execfile(os.path.join(sys.path[0], 'framework.py')) |
---|
| 5 | |
---|
| 6 | from Testing import ZopeTestCase |
---|
| 7 | from Products.SimpleBlog.tests import SimpleBlogTC |
---|
| 8 | from Products.SimpleBlog.config import ENTRY_IS_FOLDERISH |
---|
| 9 | |
---|
| 10 | # A test class defines a set of tests |
---|
| 11 | class TestInstallation(SimpleBlogTC.SimpleBlogTestCase): |
---|
| 12 | |
---|
| 13 | # The afterSetUp method can be used to define test class variables |
---|
| 14 | # and perform initialisation before tests are run. The beforeTearDown() |
---|
| 15 | # method can also be used to clean up anything set up in afterSetUp(), |
---|
| 16 | # though it is less commonly used since test always run in a sandbox |
---|
| 17 | # that is cleared after the test is run. |
---|
| 18 | def afterSetUp(self): |
---|
| 19 | self.css = self.portal.portal_css |
---|
| 20 | self.kupu = self.portal.kupu_library_tool |
---|
| 21 | self.skins = self.portal.portal_skins |
---|
| 22 | self.types = self.portal.portal_types |
---|
| 23 | self.factory = self.portal.portal_factory |
---|
| 24 | self.workflow = self.portal.portal_workflow |
---|
| 25 | self.properties = self.portal.portal_properties |
---|
| 26 | self.siteprops = self.properties.site_properties |
---|
| 27 | self.nav_props = self.portal.portal_properties.navtree_properties |
---|
| 28 | self.actions = self.portal.portal_actions |
---|
| 29 | self.icons = self.portal.portal_actionicons |
---|
| 30 | self.metaTypes = ('Blog', 'BlogFolder', 'BlogEntry') |
---|
| 31 | |
---|
| 32 | |
---|
| 33 | def testSkinLayersInstalled(self): |
---|
| 34 | self.failUnless('SimpleBlog' in self.skins.objectIds()) |
---|
| 35 | |
---|
| 36 | def testNewPermissions(self): |
---|
| 37 | managerPermission = [n['name'] for n in self.portal.permissionsOfRole('Manager')] |
---|
| 38 | self.failUnless('SimpleBlog: Cross-post' in managerPermission) |
---|
| 39 | self.failUnless('SimpleBlog: Add BlogEntry' in managerPermission) |
---|
| 40 | self.failUnless('SimpleBlog: Add Blog' in managerPermission) |
---|
| 41 | self.failUnless('SimpleBlog: Add BlogFolder' in managerPermission) |
---|
| 42 | |
---|
| 43 | def testTypesInstalled(self): |
---|
| 44 | for t in self.metaTypes: |
---|
| 45 | self.failUnless(t in self.types.objectIds()) |
---|
| 46 | |
---|
| 47 | def testPortalFactorySetup(self): |
---|
| 48 | for t in self.metaTypes: |
---|
| 49 | self.failUnless(t in self.factory.getFactoryTypes()) |
---|
| 50 | |
---|
| 51 | def testToolInstalled(self): |
---|
| 52 | self.failUnless('simpleblog_tool' in self.portal.objectIds()) |
---|
| 53 | |
---|
| 54 | def testUseFolderTabs(self): |
---|
| 55 | self.failUnless('Blog' in self.siteprops.use_folder_tabs) |
---|
| 56 | self.failUnless('BlogFolder' in self.siteprops.use_folder_tabs) |
---|
| 57 | if ENTRY_IS_FOLDERISH: |
---|
| 58 | self.failUnless('BlogEntry' in self.siteprops.use_folder_tabs) |
---|
| 59 | else: |
---|
| 60 | self.failIf('BlogEntry' in self.siteprops.use_folder_tabs) |
---|
| 61 | |
---|
| 62 | def testUserFolderContents(self): |
---|
| 63 | self.failUnless('Blog' in self.siteprops.use_folder_contents) |
---|
| 64 | self.failUnless('BlogFolder' in self.siteprops.use_folder_contents) |
---|
| 65 | if ENTRY_IS_FOLDERISH: |
---|
| 66 | self.failUnless('BlogEntry' in self.siteprops.use_folder_contents) |
---|
| 67 | else: |
---|
| 68 | self.failIf('BlogEntry' in self.siteprops.use_folder_contents) |
---|
| 69 | |
---|
| 70 | def testEntriesNotInNavtree(self): |
---|
| 71 | self.failUnless('BlogEntry' in self.nav_props.metaTypesNotToList) |
---|
| 72 | |
---|
| 73 | def testCSSRegistration(self): |
---|
| 74 | self.failUnless('SimpleBlogCSS.css' in self.css.getResourceIds()) |
---|
| 75 | |
---|
| 76 | def testDefaultPage(self): |
---|
| 77 | self.failUnless('Blog' in self.siteprops.default_page_types) |
---|
| 78 | |
---|
| 79 | def testDiscussionEnabled(self): |
---|
| 80 | self.failUnlessEqual(self.portal.portal_types.BlogEntry.allow_discussion, 1) |
---|
| 81 | |
---|
| 82 | def testControlPanel(self): |
---|
| 83 | actions = self.portal.portal_controlpanel.listActions() |
---|
| 84 | self.failUnless('SimpleBlogSetup' in [a.id for a in actions]) |
---|
| 85 | |
---|
| 86 | def testWorkflowInstalled(self): |
---|
| 87 | self.failUnless('simpleblog_workflow' in self.workflow.getWorkflowIds()) |
---|
| 88 | |
---|
| 89 | def testWorkflowAssignments(self): |
---|
| 90 | self.assertEqual(self.workflow.getChainForPortalType('Blog'), ('folder_workflow',)) |
---|
| 91 | self.assertEqual(self.workflow.getChainForPortalType('BlogFolder'), ('folder_workflow',)) |
---|
| 92 | self.assertEqual(self.workflow.getChainForPortalType('BlogEntry'), ('simpleblog_workflow',)) |
---|
| 93 | |
---|
| 94 | def testIndices(self): |
---|
| 95 | indices = self.portal.portal_catalog.indexes() |
---|
| 96 | test_indices = ['getAlwaysOnTop', |
---|
| 97 | 'EntryCategory'] |
---|
| 98 | for i in test_indices: |
---|
| 99 | self.failUnless(i in indices) |
---|
| 100 | |
---|
| 101 | |
---|
| 102 | |
---|
| 103 | # This boilerplate method sets up the test suite |
---|
| 104 | def test_suite(): |
---|
| 105 | from unittest import TestSuite, makeSuite |
---|
| 106 | suite = TestSuite() |
---|
| 107 | # Add our test class here - you can add more test classes if you wish, |
---|
| 108 | # and they will be run together. |
---|
| 109 | suite.addTest(makeSuite(TestInstallation)) |
---|
| 110 | return suite |
---|
| 111 | |
---|
| 112 | if __name__ == '__main__': |
---|
| 113 | framework() |
---|
| 114 | |
---|