[Zope3-checkins] CVS: zopeproducts/zwiki/tests - test_index.py:1.3
test_traversable.py:1.5 test_traverser.py:1.5
test_wikimail.py:1.5 test_wikipagehierarchy.py:1.10
Philipp von Weitershausen
philikon at philikon.de
Thu Sep 25 11:06:34 EDT 2003
Update of /cvs-repository/zopeproducts/zwiki/tests
In directory cvs.zope.org:/tmp/cvs-serv3518/tests
Modified Files:
test_index.py test_traversable.py test_traverser.py
test_wikimail.py test_wikipagehierarchy.py
Log Message:
Fixes for parentgeddon:
- ContextWrappers are gone
- use setitem instead of setObject
=== zopeproducts/zwiki/tests/test_index.py 1.2 => 1.3 ===
--- zopeproducts/zwiki/tests/test_index.py:1.2 Thu Jun 5 09:34:26 2003
+++ zopeproducts/zwiki/tests/test_index.py Thu Sep 25 11:06:33 2003
@@ -19,6 +19,7 @@
from zope.interface import implements
from zope.app.index.text.tests import test_index
from zope.app.interfaces.index.text import ISearchableText
+from zope.app.interfaces.container import IContained
from zope.app.services.tests.placefulsetup import PlacefulSetup
from zopeproducts.zwiki.interfaces import IWikiPage
@@ -26,7 +27,10 @@
class FakeSearchableObject:
- implements(ISearchableText, IWikiPage)
+ implements(ISearchableText, IWikiPage, IContained)
+
+ __parent__ = None
+ __name__ = None
def __init__(self):
self.texts = [u"Bruce"]
@@ -45,9 +49,9 @@
PlacefulSetup.setUp(self)
self.buildFolders()
self.index = WikiTextIndex()
- self.rootFolder.setObject('myIndex', self.index)
+ self.rootFolder['myIndex'] = self.index
self.object = FakeSearchableObject()
- self.rootFolder.setObject('bruce', self.object)
+ self.rootFolder['bruce'] = self.object
def test_suite():
=== zopeproducts/zwiki/tests/test_traversable.py 1.4 => 1.5 ===
--- zopeproducts/zwiki/tests/test_traversable.py:1.4 Thu Jun 5 09:34:26 2003
+++ zopeproducts/zwiki/tests/test_traversable.py Thu Sep 25 11:06:33 2003
@@ -18,23 +18,30 @@
import unittest, sys
from zope.exceptions import NotFoundError
from zope.testing.cleanup import CleanUp
-from zope.app.context import ContextWrapper
from zopeproducts.zwiki.wiki import Wiki
from zopeproducts.zwiki.wikipage import WikiPage
from zopeproducts.zwiki.traversal import WikiPageTraversable
+from zope.app.services.tests.placefulsetup import PlacefulSetup
+
+class TestTraversable(PlacefulSetup, CleanUp, unittest.TestCase):
+
+ def setUp(self):
+ PlacefulSetup.setUp(self)
-class TestTraversable(CleanUp, unittest.TestCase):
def testAttr(self):
# test container path traversal
wiki = Wiki()
page1 = WikiPage()
page2 = WikiPage()
- wiki.setObject('FrontPage', page1)
- wiki.setObject('FooBar', page2)
+ wiki['FrontPage'] = page1
+ wiki['FooBar'] = page2
+ # get the items again so they'll be wrapped in ContainedProxy
+ page1 = wiki['FrontPage']
+ page2 = wiki['FooBar']
- T = WikiPageTraversable(ContextWrapper(page1, wiki, name='FrontPage'))
+ T = WikiPageTraversable(page1)
self.failUnless(T.traverse('FooBar', (), 'FooBar', []) is page2)
self.assertRaises(NotFoundError , T.traverse,
=== zopeproducts/zwiki/tests/test_traverser.py 1.4 => 1.5 ===
--- zopeproducts/zwiki/tests/test_traverser.py:1.4 Thu Jun 5 09:34:26 2003
+++ zopeproducts/zwiki/tests/test_traverser.py Thu Sep 25 11:06:33 2003
@@ -24,7 +24,6 @@
from zope.exceptions import NotFoundError
from zope.app.tests.placelesssetup import PlacelessSetup
from zope.proxy import removeAllProxies
-from zope.app.context import ContextWrapper
from zopeproducts.zwiki.interfaces import IWikiPage
from zopeproducts.zwiki.wiki import Wiki
@@ -34,44 +33,45 @@
class I(Interface):
pass
-
class Request(Request):
def getEffectiveURL(self):
return ''
-
class View:
def __init__(self, comp, request):
self._comp = comp
-
class TestTraverser(PlacelessSetup, unittest.TestCase):
+
def testAttr(self):
wiki = Wiki()
page1 = WikiPage()
page2 = WikiPage()
- wiki.setObject('FrontPage', page1)
- wiki.setObject('FooBar', page2)
+ wiki['FrontPage'] = page1
+ wiki['FooBar'] = page2
+ # get the items again so they'll be wrapped in ContainedProxy
+ page1 = wiki['FrontPage']
+ page2 = wiki['FooBar']
request = Request(I, '')
- T = WikiPageTraverser(ContextWrapper(page1, wiki, name='FrontPage'),
- request)
+ T = WikiPageTraverser(page1, request)
self.failUnless(
removeAllProxies(T.publishTraverse(request, 'FooBar')) is page2)
self.assertRaises(NotFoundError, T.publishTraverse, request,'morebar')
-
def testView(self):
wiki = Wiki()
page1 = WikiPage()
page2 = WikiPage()
- wiki.setObject('FrontPage', page1)
- wiki.setObject('FooBar', page2)
+ wiki['FrontPage'] = page1
+ wiki['FooBar'] = page2
+ # get the items again so they'll be wrapped in ContainedProxy
+ page1 = wiki['FrontPage']
+ page2 = wiki['FooBar']
request = Request(I, '')
- T = WikiPageTraverser(ContextWrapper(page1, wiki, name='FrontPage'),
- request)
+ T = WikiPageTraverser(page1, request)
getService(None, Views).provideView(IWikiPage, 'viewfoo', I, [View])
self.failUnless(
=== zopeproducts/zwiki/tests/test_wikimail.py 1.4 => 1.5 ===
--- zopeproducts/zwiki/tests/test_wikimail.py:1.4 Wed Jul 9 07:20:03 2003
+++ zopeproducts/zwiki/tests/test_wikimail.py Thu Sep 25 11:06:33 2003
@@ -19,10 +19,10 @@
from zope.interface import classImplements
from zope.component.adapter import provideAdapter
-from zope.component.tests.placelesssetup import PlacelessSetup
+from zope.app.tests.placelesssetup import PlacelessSetup
+from zope.app.services.tests.placefulsetup import PlacefulSetup
from zope.app.interfaces.annotation import IAnnotations, IAttributeAnnotatable
from zope.app.interfaces.event import ISubscriber
-from zope.app.context import ContextWrapper
from zope.app.attributeannotations import AttributeAnnotations
from zopeproducts.zwiki.interfaces import IWikiPage, IWiki, IMailSubscriptions
@@ -95,14 +95,14 @@
return Wiki()
-class WikiMailerTest(PlacelessSetup, unittest.TestCase):
+class WikiMailerTest(PlacefulSetup, unittest.TestCase):
# Note: There are several other methods in this class, but they require
# mail to be sent out. One way to still write tests for these would
# be to implement a dummy smtplib.SMTP class...not now though. ;)
def setUp(self):
- PlacelessSetup.setUp(self)
+ PlacefulSetup.setUp(self)
# This needs to be done, since the IAttributeAnnotable interface
# is usually set in the ZCML
classImplements(WikiPage, IAttributeAnnotatable)
@@ -124,11 +124,11 @@
page = WikiPage()
page_sub = MailSubscriptions(page)
page_sub.context.__annotations__[SubscriberKey] = ('blah at bar.com',)
- wiki.setObject('page1', page)
- wrapped_page = ContextWrapper(page, wiki, name="page1")
+ wiki['page1'] = page
+ # get the item again so it'll be wrapped in ContainedProxy
+ page = wiki['page1']
self.assertEqual(('blah at bar.com', 'foo at bar.com'),
- mailer.getAllSubscribers(wrapped_page))
-
+ mailer.getAllSubscribers(page))
def test_suite():
return unittest.TestSuite((
=== zopeproducts/zwiki/tests/test_wikipagehierarchy.py 1.9 => 1.10 ===
--- zopeproducts/zwiki/tests/test_wikipagehierarchy.py:1.9 Wed Jul 9 07:20:03 2003
+++ zopeproducts/zwiki/tests/test_wikipagehierarchy.py Thu Sep 25 11:06:33 2003
@@ -21,25 +21,25 @@
from zopeproducts.zwiki.wikipage import WikiPage, WikiPageHierarchyAdapter
from zopeproducts.zwiki.wiki import Wiki
from zope.interface import implements, classImplements
-from zope.component.tests.placelesssetup import PlacelessSetup
from zope.component.adapter import provideAdapter
from zope.app.interfaces.annotation import IAnnotations, IAttributeAnnotatable
from zope.app.interfaces.traversing import IPhysicallyLocatable
+from zope.app.interfaces.location import ILocation
-from zope.app.context import ContextWrapper
+from zope.app.services.tests.placefulsetup import PlacefulSetup
from zope.app.attributeannotations import AttributeAnnotations
-from zope.app.traversing.adapters import WrapperPhysicallyLocatable
+from zope.app.location import LocationPhysicallyLocatable
class TestAnnotations(dict):
implements(IAnnotations)
-class Test(PlacelessSetup, unittest.TestCase):
+class Test(PlacefulSetup, unittest.TestCase):
def setUp(self):
- PlacelessSetup.setUp(self)
+ PlacefulSetup.setUp(self)
# This needs to be done, since the IAttributeAnnotable interface
# is usually set in the ZCML
classImplements(WikiPage, IAttributeAnnotatable);
@@ -47,7 +47,7 @@
AttributeAnnotations)
provideAdapter(IWikiPage, IWikiPageHierarchy,
WikiPageHierarchyAdapter)
- provideAdapter(None, IPhysicallyLocatable, WrapperPhysicallyLocatable)
+ provideAdapter(ILocation, IPhysicallyLocatable, LocationPhysicallyLocatable)
self.page = WikiPage()
def makeTestObject(self):
@@ -75,11 +75,9 @@
def test_wikipath(self):
wiki = Wiki()
- wiki.setObject('TopLevelPage', WikiPage())
- wiki.setObject('SecondLevelPage', WikiPage())
- hier = WikiPageHierarchyAdapter(
- ContextWrapper(wiki['SecondLevelPage'], wiki,
- name='SecondLevelPage'))
+ wiki['TopLevelPage'] = WikiPage()
+ wiki['SecondLevelPage'] = WikiPage()
+ hier = WikiPageHierarchyAdapter(wiki['SecondLevelPage'])
hier.reparent(('TopLevelPage',))
self.assertEqual([wiki['TopLevelPage'], wiki['SecondLevelPage']],
hier.path())
@@ -88,26 +86,29 @@
wiki = Wiki()
page1 = WikiPage()
- wiki.setObject('TopLevelPage', page1)
- wrapped_page1 = ContextWrapper(page1, wiki, name='TopLevelPage')
- hier1 = WikiPageHierarchyAdapter(wrapped_page1)
+ wiki['TopLevelPage'] = page1
+ # get the item again so it'll be wrapped in ContainedProxy
+ page1 = wiki['TopLevelPage']
+ hier1 = WikiPageHierarchyAdapter(page1)
page2 = WikiPage()
- wiki.setObject('SecondLevelPage', page2)
- wrapped_page2 = ContextWrapper(page2, wiki, name='SecondLevelPage')
- hier2 = WikiPageHierarchyAdapter(wrapped_page2)
+ wiki['SecondLevelPage'] = page2
+ # get the item again so it'll be wrapped in ContainedProxy
+ page2 = wiki['SecondLevelPage']
+ hier2 = WikiPageHierarchyAdapter(page2)
hier2.reparent(('TopLevelPage',))
page3 = WikiPage()
- wiki.setObject('ThirdLevelPage', page3)
- wrapped_page3 = ContextWrapper(page3, wiki, name='ThirdLevelPage')
- hier3 = WikiPageHierarchyAdapter(wrapped_page3)
+ wiki['ThirdLevelPage'] = page3
+ # get the item again so it'll be wrapped in ContainedProxy
+ page3 = wiki['ThirdLevelPage']
+ hier3 = WikiPageHierarchyAdapter(page3)
hier3.reparent(('SecondLevelPage',))
- self.assertEqual(( (wrapped_page2, ()), ),
+ self.assertEqual(( (page2, ()), ),
hier1.findChildren(False));
- self.assertEqual(((wrapped_page2, ((wrapped_page3, ()),) ),),
+ self.assertEqual(((page2, ((page3, ()),) ),),
hier1.findChildren());
More information about the Zope3-Checkins
mailing list