[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/index/text/tests - test_index.py:1.3
Guido van Rossum
guido@python.org
Wed, 4 Dec 2002 09:22:59 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/index/text/tests
In directory cvs.zope.org:/tmp/cvs-serv7938/tests
Modified Files:
test_index.py
Log Message:
Add subscribe and unsubscribe; refactored; added unit test for these.
=== Zope3/lib/python/Zope/App/index/text/tests/test_index.py 1.2 => 1.3 ===
--- Zope3/lib/python/Zope/App/index/text/tests/test_index.py:1.2 Wed Dec 4 07:09:28 2002
+++ Zope3/lib/python/Zope/App/index/text/tests/test_index.py Wed Dec 4 09:22:59 2002
@@ -111,6 +111,30 @@
self.assertEqual(self.index.query(u"Bruce"), ([], 0))
self.assertEqual(self.index.query(u"Sheila"), ([], 0))
+ def testBootstrap(self):
+ hub = ObjectHub()
+ location = "/bruce"
+ traverser = FakeTraverser(self.object, location)
+ provideAdapter(None, ITraverser, lambda dummy: traverser)
+ hubid = hub.register(location)
+ self.index.subscribe(hub)
+ results, total = self.index.query(u"Bruce")
+ self.assertEqual(total, 1)
+ self.assertEqual(results[0][0], hubid)
+
+ self.index.unsubscribe(hub)
+ results, total = self.index.query(u"Bruce")
+ self.assertEqual(total, 1)
+ self.assertEqual(results[0][0], hubid)
+
+ self.object.texts = [u"Sheila"]
+ event = ObjectModifiedEvent(self.object, location)
+ hub.notify(event)
+ results, total = self.index.query(u"Bruce")
+ self.assertEqual(total, 1)
+ self.assertEqual(results[0][0], hubid)
+ self.assertEqual(self.index.query(u"Sheila"), ([], 0))
+
def test_suite():
return makeSuite(Test)