Back to index

plone3  3.1.7
test_tool.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 from Products.ATContentTypes.tests import atcttestcase, atctftestcase
00027 from Products.ATContentTypes.config import TOOLNAME
00028 from Products.ATContentTypes.interfaces import IATCTTool
00029 from Interface.Verify import verifyObject
00030 from Products.CMFCore.utils import getToolByName
00031 
00032 # z3 imports
00033 from Products.ATContentTypes.interface import IATCTTool as Z3IATCTTool
00034 from zope.interface.verify import verifyObject as Z3verifyObject
00035 
00036 tests = []
00037 
00038 class TestTool(atcttestcase.ATCTSiteTestCase):
00039 
00040     def afterSetUp(self):
00041         self.tool = getToolByName(self.portal, TOOLNAME)
00042         
00043     def test_interface(self):
00044         t = self.tool
00045         self.failUnless(IATCTTool.isImplementedBy(t))
00046         self.failUnless(verifyObject(IATCTTool, t))
00047 
00048     def test_Z3interface(self):
00049         t = self.tool
00050         iface = Z3IATCTTool
00051         self.failUnless(Z3verifyObject(iface, t))
00052         
00053     def test_names(self):
00054         t = self.tool
00055         self.failUnlessEqual(t.meta_type, 'ATCT Tool')
00056         self.failUnlessEqual(t.getId(), TOOLNAME)
00057         self.failUnlessEqual(t.title, 'ATContentTypes Tool')
00058 
00059 tests.append(TestTool)
00060 
00061 
00062 class TestATCTToolFunctional(atctftestcase.IntegrationTestCase):
00063     
00064     zmi_tabs = ('manage_imageScales', 'manage_overview', )
00065     
00066     def setupTestObject(self):
00067         self.obj_id = TOOLNAME
00068         self.obj = getToolByName(self.portal, TOOLNAME)
00069         self.obj_url = self.obj.absolute_url()
00070         self.obj_path = '/%s' % self.obj.absolute_url(1)
00071 
00072     def test_zmi_tabs(self):
00073         for view in self.zmi_tabs:
00074             response = self.publish('%s/%s' % (self.obj_path, view), self.owner_auth)
00075             self.assertStatusEqual(response.getStatus(), 200, 
00076                 "%s: %s" % (view, response.getStatus())) # OK
00077 
00078 tests.append(TestATCTToolFunctional)
00079 
00080 import unittest
00081 def test_suite():
00082     suite = unittest.TestSuite()
00083     for test in tests:
00084         suite.addTest(unittest.makeSuite(test))
00085     return suite