Back to index

plone3  3.1.7
test_adapters.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
00027 from Acquisition import aq_base
00028 
00029 from Products.Archetypes.atapi import *
00030 
00031 from Products.ATContentTypes.content.folder import ATFolder
00032 from Products.ATContentTypes.interfaces import IATFolder
00033 
00034 from Products.ATContentTypes.interface.image import IPhotoAlbum
00035 from Products.ATContentTypes.interface.image import IPhotoAlbumAble
00036 from Products.ATContentTypes.interface.archive import IArchiver
00037 from Products.ATContentTypes.interface.archive import IArchivable
00038 from Products.ATContentTypes.interface.archive import IDataExtractor
00039 from Products.ATContentTypes.adapters.document import DocumentDataExtractor
00040 from Products.ATContentTypes.adapters.document import DocumentRawDataExtractor
00041 from Products.ATContentTypes.interface.archive import IArchiveAccumulator
00042 from Products.ATContentTypes.adapters.archive import ZipAccumulator
00043 
00044 from Products.ATContentTypes.adapters.image import PhotoAlbum
00045 from Products.ATContentTypes.adapters.archive import FolderishArchiver
00046 
00047 from Products.ATContentTypes.browser.archive import ArchiveView
00048 
00049 from zope.interface.verify import verifyClass
00050 from zipfile import ZipFile
00051 from cStringIO import StringIO
00052 
00053 tests = []
00054 
00055 class TestAccumulator(atcttestcase.ATCTSiteTestCase):
00056 
00057     def test_adapter(self):
00058         verifyClass(IArchiveAccumulator, ZipAccumulator)
00059 
00060 tests.append(TestAccumulator)
00061 
00062 class TestDataExtractors(atcttestcase.ATCTSiteTestCase):
00063     def afterSetUp(self):
00064         atcttestcase.ATCTSiteTestCase.afterSetUp(self)
00065         self.folder.invokeFactory('Document', 'd1', title='doc 1')
00066         self.docobj = self.folder.d1
00067 
00068     def test_adapter(self):
00069         IDataExtractor.implementedBy(DocumentDataExtractor)
00070         IDataExtractor.implementedBy(DocumentRawDataExtractor)
00071 
00072 tests.append(TestDataExtractors)
00073 
00074 
00075 class TestSitePhotoAlbumSupport(atcttestcase.ATCTSiteTestCase):
00076     def afterSetUp(self):
00077         atcttestcase.ATCTSiteTestCase.afterSetUp(self)
00078         self.folder.invokeFactory('Folder', 'fobj', title='folder 1')
00079         self.fobj = self.folder.fobj
00080 
00081     def test_implements(self):
00082         self.failUnless(IPhotoAlbumAble.providedBy(self.fobj))
00083 
00084     def test_adapter(self):
00085         verifyClass(IPhotoAlbum,PhotoAlbum)
00086 
00087     def test_SymbolicPhoto(self):
00088         adapted = IPhotoAlbum(self.fobj)
00089 
00090 tests.append(TestSitePhotoAlbumSupport)
00091 
00092 class TestFolderishArchiver(atcttestcase.ATCTSiteTestCase):
00093     def afterSetUp(self):
00094         atcttestcase.ATCTSiteTestCase.afterSetUp(self)
00095         self.folder.invokeFactory('Folder', 'fobj', title='folder 1')
00096         self.fobj = self.folder.fobj
00097         self.fobj.invokeFactory('Document','doc1',title='document 1')
00098         self.fobj.doc1.setText("A nice text")
00099 
00100     def test_implements(self):
00101         archiver = IArchiver(self.fobj)
00102         self.failUnless(IArchiver.providedBy(archiver))
00103 
00104     def test_adapter(self):
00105         verifyClass(IArchiver,FolderishArchiver)
00106 
00107 tests.append(TestFolderishArchiver)
00108 
00109 import unittest
00110 def test_suite():
00111     suite = unittest.TestSuite()
00112     for test in tests:
00113         suite.addTest(unittest.makeSuite(test))
00114     return suite