Back to index

plone3  3.1.7
test_installation.py
Go to the documentation of this file.
00001 #  ATContentTypes http://plone.org/products/atcontenttypes/
00002 #  Archetypes reimplementation of the CMF core types
00003 #  Copyright (c) 2003-2006 AT Content Types development team
00004 #
00005 #  This program is free software; you can redistribute it and/or modify
00006 #  it under the terms of the GNU General Public License as published by
00007 #  the Free Software Foundation; either version 2 of the License, or
00008 #  (at your option) any later version.
00009 #
00010 #  This program is distributed in the hope that it will be useful,
00011 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 #  GNU General Public License for more details.
00014 #
00015 #  You should have received a copy of the GNU General Public License
00016 #  along with this program; if not, write to the Free Software
00017 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 #
00019 """
00020 """
00021 
00022 __author__ = 'Christian Heimes <tiran@cheimes.de>'
00023 __docformat__ = 'restructuredtext'
00024 
00025 from Testing import ZopeTestCase # side effect import. leave it here.
00026 
00027 import transaction
00028 from Products.ATContentTypes.tests import atcttestcase
00029 from Products.ATContentTypes.config import TOOLNAME
00030 from Products.ATContentTypes.config import SWALLOW_IMAGE_RESIZE_EXCEPTIONS
00031 from Products.ATContentTypes.tool.atct import ATCTTool
00032 from Products.CMFCore.utils import getToolByName
00033 from StringIO import StringIO
00034 
00035 tests = []
00036 
00037 class TestInstallation(atcttestcase.ATCTSiteTestCase):
00038 
00039     def afterSetUp(self):
00040         self.tool = getattr(self.portal.aq_explicit, TOOLNAME)
00041         self.ttool = getattr(self.portal.aq_explicit, 'portal_types')
00042         self.cat = getattr(self.portal.aq_explicit, 'portal_catalog')
00043 
00044     def test_tool_installed(self):
00045         t = getToolByName(self.portal, TOOLNAME, None)
00046         self.failUnless(t, t)
00047         self.failUnless(isinstance(t, ATCTTool), t.__class__)
00048         self.failUnlessEqual(t.meta_type, 'ATCT Tool')
00049         self.failUnlessEqual(t.getId(), TOOLNAME)
00050 
00051     def test_skin_installed(self):
00052         stool = getattr(self.portal.aq_explicit, 'portal_skins')
00053         ids = stool.objectIds()
00054         self.failUnless('ATContentTypes' in ids, ids)
00055 
00056     def test_installedAllTypes(self):
00057         # test that all types are installed well
00058         ttool = self.ttool
00059         ids = ('Document', 'Favorite', 'File',
00060             'Folder', 'Image', 'Large Plone Folder', 'Link',
00061             'News Item', 'Topic', 'Event')
00062 
00063         tids = ttool.objectIds()
00064         for id in ids:
00065             self.failUnless(id in tids, (id, tids))
00066             tinfo = ttool[id]
00067             self.failUnless(tinfo.product == 'ATContentTypes', tinfo.product)
00068 
00069     def test_not_quickinstalled(self):
00070         qi = getattr(self.portal, 'portal_quickinstaller')
00071         products = [prod['id'] for prod in qi.listInstalledProducts()]
00072         self.failIf('ATContentTypes' in products)
00073 
00074     def test_release_settings_SAVE_TO_FAIL_FOR_DEVELOPMENT(self):
00075         self.failUnlessEqual(SWALLOW_IMAGE_RESIZE_EXCEPTIONS, True)
00076 
00077     def test_reindex_doesnt_add_tools(self):
00078         cat = self.cat
00079         ids = [id for id in self.portal.objectIds()
00080                if id.startswith('portal_') ]
00081         # a rought guess
00082         self.failIf(len(ids) < 5)
00083         for id in ids:
00084                 result = cat(id=id)
00085                 l = len(result)
00086                 self.failUnlessEqual(l, 0, (id, l, result))
00087 
00088     def test_adds_related_items_catalog_index(self):
00089         self.assertEqual(self.cat.Indexes['getRawRelatedItems'].__class__.__name__,
00090                          'KeywordIndex')
00091 
00092     def test_api_import(self):
00093         import Products.ATContentTypes.atct
00094 
00095 
00096 tests.append(TestInstallation)
00097 
00098 import unittest
00099 def test_suite():
00100     suite = unittest.TestSuite()
00101     for test in tests:
00102         suite.addTest(unittest.makeSuite(test))
00103     return suite