Back to index

plone3  3.1.7
test_exportimport.py
Go to the documentation of this file.
00001 ##############################################################################
00002 #
00003 # Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
00004 #
00005 # This software is subject to the provisions of the Zope Public License,
00006 # Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
00007 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
00008 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00009 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
00010 # FOR A PARTICULAR PURPOSE.
00011 #
00012 ##############################################################################
00013 """PluginIndexes export / import support unit tests.
00014 
00015 $Id: test_exportimport.py 71212 2006-11-20 19:27:48Z yuppie $
00016 """
00017 
00018 import unittest
00019 import Testing
00020 
00021 from Products.GenericSetup.testing import NodeAdapterTestCase
00022 from Products.GenericSetup.testing import ExportImportZCMLLayer
00023 
00024 _DATE_XML = """\
00025 <index name="foo_date" meta_type="DateIndex">
00026  <property name="index_naive_time_as_local">True</property>
00027 </index>
00028 """
00029 
00030 _DATERANGE_XML = """\
00031 <index name="foo_daterange" meta_type="DateRangeIndex" since_field="bar"
00032    until_field="baz"/>
00033 """
00034 
00035 _FIELD_XML = """\
00036 <index name="foo_field" meta_type="FieldIndex">
00037  <indexed_attr value="bar"/>
00038 </index>
00039 """
00040 
00041 _KEYWORD_XML = """\
00042 <index name="foo_keyword" meta_type="KeywordIndex">
00043  <indexed_attr value="bar"/>
00044 </index>
00045 """
00046 
00047 _PATH_XML = """\
00048 <index name="foo_path" meta_type="PathIndex"/>
00049 """
00050 
00051 _VOCABULARY_XML = """\
00052 <object name="foo_vocabulary" meta_type="Vocabulary" deprecated="True"/>
00053 """
00054 
00055 _TEXT_XML = """\
00056 <index name="foo_text" meta_type="TextIndex" deprecated="True"/>
00057 """
00058 
00059 _SET_XML = """\
00060 <filtered_set name="bar" meta_type="PythonFilteredSet" expression="True"/>
00061 """
00062 
00063 _TOPIC_XML = """\
00064 <index name="foo_topic" meta_type="TopicIndex">
00065  <filtered_set name="bar" meta_type="PythonFilteredSet" expression="True"/>
00066  <filtered_set name="baz" meta_type="PythonFilteredSet" expression="False"/>
00067 </index>
00068 """
00069 
00070 
00071 class DateIndexNodeAdapterTests(NodeAdapterTestCase):
00072 
00073     layer = ExportImportZCMLLayer
00074 
00075     def _getTargetClass(self):
00076         from Products.GenericSetup.PluginIndexes.exportimport \
00077                 import DateIndexNodeAdapter
00078 
00079         return DateIndexNodeAdapter
00080 
00081     def setUp(self):
00082         from Products.PluginIndexes.DateIndex.DateIndex import DateIndex
00083 
00084         NodeAdapterTestCase.setUp(self)
00085         self._obj = DateIndex('foo_date')
00086         self._XML = _DATE_XML
00087 
00088 
00089 class DateRangeIndexNodeAdapterTests(NodeAdapterTestCase):
00090 
00091     layer = ExportImportZCMLLayer
00092 
00093     def _getTargetClass(self):
00094         from Products.GenericSetup.PluginIndexes.exportimport \
00095                 import DateRangeIndexNodeAdapter
00096 
00097         return DateRangeIndexNodeAdapter
00098 
00099     def _populate(self, obj):
00100         obj._edit('bar', 'baz')
00101 
00102     def setUp(self):
00103         from Products.PluginIndexes.DateRangeIndex.DateRangeIndex \
00104                 import DateRangeIndex
00105 
00106         NodeAdapterTestCase.setUp(self)
00107         self._obj = DateRangeIndex('foo_daterange')
00108         self._XML = _DATERANGE_XML
00109 
00110 
00111 class FieldIndexNodeAdapterTests(NodeAdapterTestCase):
00112 
00113     layer = ExportImportZCMLLayer
00114 
00115     def _getTargetClass(self):
00116         from Products.GenericSetup.PluginIndexes.exportimport \
00117                 import PluggableIndexNodeAdapter
00118 
00119         return PluggableIndexNodeAdapter
00120 
00121     def _populate(self, obj):
00122         obj.indexed_attrs = ('bar',)
00123 
00124     def setUp(self):
00125         from Products.PluginIndexes.FieldIndex.FieldIndex import FieldIndex
00126 
00127         NodeAdapterTestCase.setUp(self)
00128         self._obj = FieldIndex('foo_field')
00129         self._XML = _FIELD_XML
00130 
00131 
00132 class KeywordIndexNodeAdapterTests(NodeAdapterTestCase):
00133 
00134     layer = ExportImportZCMLLayer
00135 
00136     def _getTargetClass(self):
00137         from Products.GenericSetup.PluginIndexes.exportimport \
00138                 import PluggableIndexNodeAdapter
00139 
00140         return PluggableIndexNodeAdapter
00141 
00142     def _populate(self, obj):
00143         obj.indexed_attrs = ('bar',)
00144 
00145     def setUp(self):
00146         from Products.PluginIndexes.KeywordIndex.KeywordIndex \
00147                 import KeywordIndex
00148 
00149         NodeAdapterTestCase.setUp(self)
00150         self._obj = KeywordIndex('foo_keyword')
00151         self._XML = _KEYWORD_XML
00152 
00153 
00154 class PathIndexNodeAdapterTests(NodeAdapterTestCase):
00155 
00156     layer = ExportImportZCMLLayer
00157 
00158     def _getTargetClass(self):
00159         from Products.GenericSetup.PluginIndexes.exportimport \
00160                 import PathIndexNodeAdapter
00161 
00162         return PathIndexNodeAdapter
00163 
00164     def setUp(self):
00165         from Products.PluginIndexes.PathIndex.PathIndex import PathIndex
00166 
00167         NodeAdapterTestCase.setUp(self)
00168         self._obj = PathIndex('foo_path')
00169         self._XML = _PATH_XML
00170 
00171 
00172 class VocabularyNodeAdapterTests(NodeAdapterTestCase):
00173 
00174     layer = ExportImportZCMLLayer
00175 
00176     def _getTargetClass(self):
00177         from Products.GenericSetup.PluginIndexes.exportimport \
00178                 import VocabularyNodeAdapter
00179 
00180         return VocabularyNodeAdapter
00181 
00182     def setUp(self):
00183         from Products.PluginIndexes.TextIndex.Vocabulary import Vocabulary
00184 
00185         NodeAdapterTestCase.setUp(self)
00186         self._obj = Vocabulary('foo_vocabulary')
00187         self._XML = _VOCABULARY_XML
00188 
00189     def test_importNode(self):
00190         pass
00191 
00192 
00193 class TextIndexNodeAdapterTests(NodeAdapterTestCase):
00194 
00195     layer = ExportImportZCMLLayer
00196 
00197     def _getTargetClass(self):
00198         from Products.GenericSetup.PluginIndexes.exportimport \
00199                 import TextIndexNodeAdapter
00200 
00201         return TextIndexNodeAdapter
00202 
00203     def setUp(self):
00204         from Products.PluginIndexes.TextIndex.TextIndex import TextIndex
00205 
00206         NodeAdapterTestCase.setUp(self)
00207         self._obj = TextIndex('foo_text')
00208         self._XML = _TEXT_XML
00209 
00210     def test_importNode(self):
00211         pass
00212 
00213 
00214 class FilteredSetNodeAdapterTests(NodeAdapterTestCase):
00215 
00216     layer = ExportImportZCMLLayer
00217 
00218     def _getTargetClass(self):
00219         from Products.GenericSetup.PluginIndexes.exportimport \
00220                 import FilteredSetNodeAdapter
00221 
00222         return FilteredSetNodeAdapter
00223 
00224     def _populate(self, obj):
00225         obj.setExpression('True')
00226 
00227     def setUp(self):
00228         from Products.PluginIndexes.TopicIndex.FilteredSet \
00229                 import PythonFilteredSet
00230 
00231         NodeAdapterTestCase.setUp(self)
00232         self._obj = PythonFilteredSet('bar', '')
00233         self._XML = _SET_XML
00234 
00235 
00236 class TopicIndexNodeAdapterTests(NodeAdapterTestCase):
00237 
00238     layer = ExportImportZCMLLayer
00239 
00240     def _getTargetClass(self):
00241         from Products.GenericSetup.PluginIndexes.exportimport \
00242                 import TopicIndexNodeAdapter
00243 
00244         return TopicIndexNodeAdapter
00245 
00246     def _populate(self, obj):
00247         obj.addFilteredSet('bar', 'PythonFilteredSet', 'True')
00248         obj.addFilteredSet('baz', 'PythonFilteredSet', 'False')
00249 
00250     def setUp(self):
00251         from Products.PluginIndexes.TopicIndex.TopicIndex import TopicIndex
00252 
00253         NodeAdapterTestCase.setUp(self)
00254         self._obj = TopicIndex('foo_topic')
00255         self._XML = _TOPIC_XML
00256 
00257 
00258 def test_suite():
00259     return unittest.TestSuite((
00260         unittest.makeSuite(DateIndexNodeAdapterTests),
00261         unittest.makeSuite(DateRangeIndexNodeAdapterTests),
00262         unittest.makeSuite(FieldIndexNodeAdapterTests),
00263         unittest.makeSuite(KeywordIndexNodeAdapterTests),
00264         unittest.makeSuite(PathIndexNodeAdapterTests),
00265         unittest.makeSuite(VocabularyNodeAdapterTests),
00266         unittest.makeSuite(TextIndexNodeAdapterTests),
00267         unittest.makeSuite(FilteredSetNodeAdapterTests),
00268         unittest.makeSuite(TopicIndexNodeAdapterTests),
00269         ))
00270 
00271 if __name__ == '__main__':
00272     from Products.GenericSetup.testing import run
00273     run(test_suite())