[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/ZopePublication/tests - testZopePublication.py:1.1.2.9
Jim Fulton
jim@zope.com
Fri, 8 Feb 2002 08:13:07 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/ZopePublication/tests
In directory cvs.zope.org:/tmp/cvs-serv15612
Modified Files:
Tag: Zope-3x-branch
testZopePublication.py
Log Message:
Broke base tag tests into separate tests.
=== Zope3/lib/python/Zope/App/ZopePublication/tests/testZopePublication.py 1.1.2.8 => 1.1.2.9 ===
from Zope.App.Security.PrincipalRegistry import principalRegistry
from Zope.App.Security.PrincipalRoleManager import principalRoleManager
+from Zope.ComponentArchitecture import provideView
from StringIO import StringIO
@@ -46,8 +47,6 @@
def browser_traverse(self, request, name):
if name == 'bruce':
return foo
- if name == 'edit;view':
- return 'bob'
raise KeyError, name
def browser_default(self, request):
@@ -121,16 +120,22 @@
"""
klass = BrowserPublication
- _expected = "/somepath/view;view/bruce"
+ def testBaseTagNoBase(self):
+ # XXX WRONG!
+ self._testBaseTags('/somepath/view;view/', '/somepath/view;view')
- _test_urls = [
- '/somepath/view;view/',
- '/somepath/view;view',
- '/somepath/',
- '/somepath'
- ]
+ def testBaseTag1(self):
+ self._testBaseTags('/somepath/view;view', '/somepath/view;view')
- def testBaseTags(self):
+ def testBaseTag2(self):
+ self._testBaseTags('/somepath/', '/somepath/view;view')
+
+ def testBaseTag3(self):
+ self._testBaseTags('/somepath', '/somepath/view;view')
+
+
+
+ def _testBaseTags(self, url, expected):
class I1(Interface): pass
@@ -166,12 +171,11 @@
get_transaction().commit()
connection.close()
- for url in self._test_urls:
- req = self._createRequest(url, pub)
- publish(req)
+ req = self._createRequest(url, pub)
+
+ publish(req)
- self.assertEqual(req.response.getBase(),
- self._expected)
+ self.assertEqual(req.response.getBase(), expected)
def _createRequest(self, path, publication):
outstream = StringIO()
@@ -238,7 +242,6 @@
def browser_default(self, request):
return (self.context['bruce'], 'dummy')
- from Zope.ComponentArchitecture import provideView
provideView(I1, '_traverse', IBrowserPublisher, Adapter)
ob = mydict()
ob['bruce'] = 'bruce'
@@ -252,17 +255,23 @@
def testTraverseSkinExtraction(self):
+ class I1(Interface): pass
+ class C: __implements__ = I1
+ class BobView(DummyView): pass
+
pub = self.klass(self.db)
- ob = DummyPublished()
+ ob = C()
+ provideView(I1, 'edit', IBrowserPublisher, BobView)
+
r = self._createRequest('/edit;skin=zmi;view',pub)
ob2 = pub.traverseName(r , ob, 'edit;skin=zmi;view')
- self.assertEqual( r.getViewSkin(), 'zmi')
- self.assertEqual( ob2 , 'bob')
+ self.assertEqual(r.getViewSkin(), 'zmi')
+ self.assertEqual(ob2.__class__ , BobView)
r = self._createRequest('/edit;view;skin=zmi',pub)
ob2 = pub.traverseName(r , ob, 'edit;view;skin=zmi')
- self.assertEqual( r.getViewSkin(), 'zmi')
- self.assertEqual( ob2 , 'bob')
+ self.assertEqual(r.getViewSkin(), 'zmi')
+ self.assertEqual(ob2.__class__ , BobView)
def test_suite():