[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Content/ZPTPage/tests - testZPTPage.py:1.5
Benjamin Saller
bcsaller@yahoo.com
Thu, 5 Dec 2002 07:36:49 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Content/ZPTPage/tests
In directory cvs.zope.org:/tmp/cvs-serv16565/tests
Modified Files:
testZPTPage.py
Log Message:
*added SearchableText adapter to the source of a ZPT page, this still has some unicode issues to resolve
=== Zope3/lib/python/Zope/App/OFS/Content/ZPTPage/tests/testZPTPage.py 1.4 => 1.5 ===
--- Zope3/lib/python/Zope/App/OFS/Content/ZPTPage/tests/testZPTPage.py:1.4 Tue Dec 3 16:34:47 2002
+++ Zope3/lib/python/Zope/App/OFS/Content/ZPTPage/tests/testZPTPage.py Thu Dec 5 07:36:48 2002
@@ -19,7 +19,10 @@
import unittest
-from Zope.App.OFS.Content.ZPTPage.ZPTPage import ZPTPage
+from Zope.App.OFS.Content.ZPTPage.ZPTPage import ZPTPage, \
+ SearchableText, IZPTPage
+from Zope.App.index.text.interfaces import ISearchableText
+from Zope.ComponentArchitecture import getAdapter
# Wow, this is a lot of work. :(
from Zope.App.tests.PlacelessSetup import PlacelessSetup
@@ -43,8 +46,23 @@
PlacelessSetup.setUp(self)
provideAdapter(None, ITraverser, Traverser)
provideAdapter(None, ITraversable, DefaultTraversable)
+ provideAdapter(IZPTPage, ISearchableText, SearchableText)
defineChecker(Data, NamesChecker(['URL', 'name']))
-
+
+ def testSearchableText(self):
+ page = ZPTPage()
+ text = 'this is a test\n' ## The source will return with a newline if its ommited
+ utext = u'another test\n'
+
+ page.setSource(text)
+ searchableText = getAdapter(page, ISearchableText)
+ self.failUnlessEqual(searchableText.getSearchableText(), [unicode(text)])
+
+ page.setSource(utext)
+ self.failUnlessEqual(searchableText.getSearchableText(), [utext])
+
+
+
def testZPTRendering(self):
page = ZPTPage()
page.setSource(
@@ -69,6 +87,8 @@
'zope'
'</a></body></html>'
)
+
+
def test_suite():
return unittest.makeSuite(ZPTPageTests)