Back to index

plone3  3.1.7
test_modulealiases.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 """Tests for module aliases from old .types to new .content
00020 
00021 Tests if the classes can be imported from the old path but the new path is the right
00022 path for pickling.
00023 """
00024 
00025 __author__ = 'Christian Heimes <tiran@cheimes.de>'
00026 __docformat__ = 'restructuredtext'
00027 
00028 from Testing import ZopeTestCase # side effect import. leave it here.
00029 from Products.ATContentTypes.tests import atcttestcase
00030 
00031 tests = []
00032 
00033 class TestModuleAliases(atcttestcase.ATCTSiteTestCase):
00034 
00035     def test_import_content_type(self):
00036         from Products.ATContentTypes.types.ATDocument import ATDocument
00037         from Products.ATContentTypes.types.ATEvent import ATEvent
00038         from Products.ATContentTypes.types.ATFavorite import ATFavorite
00039         from Products.ATContentTypes.types.ATFile import ATFile
00040         from Products.ATContentTypes.types.ATFolder import ATFolder
00041         from Products.ATContentTypes.types.ATFolder import ATBTreeFolder
00042         from Products.ATContentTypes.types.ATImage import ATImage
00043         from Products.ATContentTypes.types.ATLink import ATLink
00044         from Products.ATContentTypes.types.ATNewsItem import ATNewsItem
00045         from Products.ATContentTypes.types.ATTopic import ATTopic
00046 
00047         self.failUnlessEqual(ATDocument.__module__,
00048             'Products.ATContentTypes.content.document')
00049         self.failUnlessEqual(ATEvent.__module__,
00050             'Products.ATContentTypes.content.event')
00051         self.failUnlessEqual(ATFavorite.__module__,
00052             'Products.ATContentTypes.content.favorite')
00053         self.failUnlessEqual(ATFile.__module__,
00054             'Products.ATContentTypes.content.file')
00055         self.failUnlessEqual(ATFolder.__module__,
00056             'Products.ATContentTypes.content.folder')
00057         self.failUnlessEqual(ATBTreeFolder.__module__,
00058             'Products.ATContentTypes.content.folder')
00059         self.failUnlessEqual(ATImage.__module__,
00060             'Products.ATContentTypes.content.image')
00061         self.failUnlessEqual(ATLink.__module__,
00062             'Products.ATContentTypes.content.link')
00063         self.failUnlessEqual(ATNewsItem.__module__,
00064             'Products.ATContentTypes.content.newsitem')
00065         self.failUnlessEqual(ATTopic.__module__,
00066             'Products.ATContentTypes.content.topic')
00067 
00068     def test_import_criteria(self):
00069         from Products.ATContentTypes.criteria.boolean import \
00070             ATBooleanCriterion
00071         from Products.ATContentTypes.criteria.date import \
00072             ATDateCriteria
00073         from Products.ATContentTypes.criteria.daterange import \
00074             ATDateRangeCriterion
00075         from Products.ATContentTypes.criteria.list import \
00076             ATListCriterion
00077         from Products.ATContentTypes.criteria.portaltype import \
00078             ATPortalTypeCriterion
00079         from Products.ATContentTypes.criteria.reference import \
00080             ATReferenceCriterion
00081         from Products.ATContentTypes.criteria.selection import \
00082             ATSelectionCriterion
00083         from Products.ATContentTypes.criteria.simpleint import \
00084             ATSimpleIntCriterion
00085         from Products.ATContentTypes.criteria.simplestring import \
00086             ATSimpleStringCriterion
00087         from Products.ATContentTypes.criteria.sort import \
00088             ATSortCriterion
00089 
00090         self.failUnlessEqual(ATBooleanCriterion.__module__,
00091             'Products.ATContentTypes.criteria.boolean')
00092         self.failUnlessEqual(ATDateCriteria.__module__,
00093             'Products.ATContentTypes.criteria.date')
00094         self.failUnlessEqual(ATDateRangeCriterion.__module__,
00095             'Products.ATContentTypes.criteria.daterange')
00096         self.failUnlessEqual(ATListCriterion.__module__,
00097             'Products.ATContentTypes.criteria.list')
00098         self.failUnlessEqual(ATPortalTypeCriterion.__module__,
00099             'Products.ATContentTypes.criteria.portaltype')
00100         self.failUnlessEqual(ATReferenceCriterion.__module__,
00101             'Products.ATContentTypes.criteria.reference')
00102         self.failUnlessEqual(ATSelectionCriterion.__module__,
00103             'Products.ATContentTypes.criteria.selection')
00104         self.failUnlessEqual(ATSimpleIntCriterion.__module__,
00105             'Products.ATContentTypes.criteria.simpleint')
00106         self.failUnlessEqual(ATSimpleStringCriterion.__module__,
00107             'Products.ATContentTypes.criteria.simplestring')
00108         self.failUnlessEqual(ATSortCriterion.__module__,
00109             'Products.ATContentTypes.criteria.sort')
00110 
00111     def test_import_z3_interfaces(self):
00112         # People import things in different ways, let's make sure they all
00113         # work (doing so actually requires more than just an alias
00114         from Products.ATContentTypes.z3.interfaces import ITextContent
00115         from Products.ATContentTypes.z3 import interfaces
00116         from Products.ATContentTypes import z3
00117 
00118         self.failUnlessEqual(ITextContent.__module__,
00119             'Products.ATContentTypes.interface.interfaces')
00120         self.failUnlessEqual(interfaces.ITextContent.__module__,
00121             'Products.ATContentTypes.interface.interfaces')
00122         self.failUnlessEqual(z3.interfaces.ITextContent.__module__,
00123             'Products.ATContentTypes.interface.interfaces')
00124 
00125 
00126 tests.append(TestModuleAliases)
00127 
00128 import unittest
00129 def test_suite():
00130     suite = unittest.TestSuite()
00131     for test in tests:
00132         suite.addTest(unittest.makeSuite(test))
00133     return suite