[Zope3-checkins] CVS: Zope3/src/zope/app/publication/tests - test_browserpublication.py:1.11.10.1 test_http.py:1.2.22.1 test_zopepublication.py:1.13.10.1
Grégoire Weber
zope@i-con.ch
Sun, 22 Jun 2003 10:24:19 -0400
Update of /cvs-repository/Zope3/src/zope/app/publication/tests
In directory cvs.zope.org:/tmp/cvs-serv24874/src/zope/app/publication/tests
Modified Files:
Tag: cw-mail-branch
test_browserpublication.py test_http.py
test_zopepublication.py
Log Message:
Synced up with HEAD
=== Zope3/src/zope/app/publication/tests/test_browserpublication.py 1.11 => 1.11.10.1 ===
--- Zope3/src/zope/app/publication/tests/test_browserpublication.py:1.11 Thu May 1 15:35:26 2003
+++ Zope3/src/zope/app/publication/tests/test_browserpublication.py Sun Jun 22 10:23:18 2003
@@ -15,7 +15,7 @@
from StringIO import StringIO
-from zope.interface import Interface
+from zope.interface import Interface, implements
from zope.component import getService
from zope.app.services.servicenames import Views
@@ -25,9 +25,9 @@
from zope.publisher.interfaces.browser \
import IBrowserPresentation, IBrowserPublisher
-from zope.proxy.context import getWrapperContext, wrapperTypes
-from zope.proxy.introspection import removeAllProxies
-from zope.security.proxy import Proxy, getObject
+from zope.context import getWrapperContext, isWrapper
+from zope.proxy import removeAllProxies, getProxiedObject
+from zope.security.proxy import Proxy
from zope.security.checker import defineChecker, NamesChecker
from zope.app.security.registries.principalregistry import principalRegistry
@@ -44,7 +44,7 @@
class DummyPublished:
- __implements__ = IBrowserPublisher
+ implements(IBrowserPublisher)
def publishTraverse(self, request, name):
if name == 'bruce':
@@ -60,8 +60,6 @@
__Security_checker__ = NamesChecker(["browserDefault", "publishTraverse"])
- __implements__ = DummyPublished.__implements__, BrowserView.__implements__
-
class BasePublicationTests(BasePublicationTests_):
@@ -108,8 +106,7 @@
from persistence import Persistent
class O1(Persistent):
- __implements__ = I1
-
+ implements(I1)
pub = BrowserPublication(self.db)
@@ -164,7 +161,7 @@
pass
class mydict(dict):
- __implements__ = I1
+ implements(I1)
class BrowserPublicationTests(BasePublicationTests):
@@ -177,14 +174,14 @@
ob2 = pub.traverseName(self._createRequest('/bruce', pub), ob, 'bruce')
self.failUnless(ob2 is not ob)
self.failUnless(type(ob2) is Proxy)
- ob2 = getObject(ob2)
- self.failUnless(type(ob2) in wrapperTypes)
+ ob2 = getProxiedObject(ob2)
+ self.failUnless(isWrapper(ob2))
def testAdaptedTraverseNameWrapping(self):
class Adapter:
" "
- __implements__ = IBrowserPublisher
+ implements(IBrowserPublisher)
def __init__(self, context, request):
self.context = context
self.counter = 0
@@ -201,15 +198,15 @@
pub = self.klass(self.db)
ob2 = pub.traverseName(self._createRequest('/bruce', pub), ob, 'bruce')
self.failUnless(type(ob2) is Proxy)
- ob2 = getObject(ob2)
- self.failUnless(type(ob2) in wrapperTypes)
+ ob2 = getProxiedObject(ob2)
+ self.failUnless(isWrapper(ob2))
unw = removeAllProxies(ob2)
self.assertEqual(unw.v, 'bruce')
def testAdaptedTraverseDefaultWrapping(self):
# Test default content and make sure that it's wrapped.
class Adapter:
- __implements__ = IBrowserPublisher
+ implements(IBrowserPublisher)
def __init__(self, context, request):
self.context = context
@@ -225,15 +222,16 @@
ob2, x = pub.getDefaultTraversal(self._createRequest('/bruce',pub), ob)
self.assertEqual(x, 'dummy')
self.failUnless(type(ob2) is Proxy)
- ob2 = getObject(ob2)
- self.failUnless(type(ob2) in wrapperTypes)
+ ob2 = getProxiedObject(ob2)
+ self.failUnless(isWrapper(ob2))
unw = removeAllProxies(ob2)
self.assertEqual(unw.v, 'bruce')
# XXX we no longer support path parameters! (At least for now)
def XXXtestTraverseSkinExtraction(self):
class I1(Interface): pass
- class C: __implements__ = I1
+ class C:
+ implements(I1)
class BobView(DummyView): pass
pub = self.klass(self.db)
@@ -267,11 +265,11 @@
pub = self.klass(self.db)
class I(Interface): pass
class C:
- __implements__ = I
+ implements(I)
ob = C()
class V:
def __init__(self, context, request): pass
- __implements__ = IBrowserPresentation
+ implements(IBrowserPresentation)
r = self._createRequest('/@@spam',pub)
provideView=getService(None, Views).provideView
provideView(I, 'spam', IBrowserPresentation, [V])
@@ -313,7 +311,7 @@
# With a normal request, we should get a body:
output = StringIO()
request = TestRequest(StringIO(''), output, {'PATH_INFO': '/'})
- request.user = User()
+ request.setUser(User())
request.response.setBody("spam")
pub.afterCall(request)
request.response.outputBody()
@@ -329,7 +327,7 @@
# But with a HEAD request, the body should be empty
output = StringIO()
request = TestRequest(StringIO(''), output, {'PATH_INFO': '/'})
- request.user = User()
+ request.setUser(User())
request.method = 'HEAD'
request.response.setBody("spam")
pub.afterCall(request)
=== Zope3/src/zope/app/publication/tests/test_http.py 1.2 => 1.2.22.1 ===
--- Zope3/src/zope/app/publication/tests/test_http.py:1.2 Tue Feb 11 10:59:53 2003
+++ Zope3/src/zope/app/publication/tests/test_http.py Sun Jun 22 10:23:19 2003
@@ -21,24 +21,23 @@
from zope.app.tests.placelesssetup import PlacelessSetup
from StringIO import StringIO
from zope.component.view import provideView
-from zope.interface import Interface
+from zope.interface import Interface, implements
from zope.publisher.interfaces.http import IHTTPPresentation
class I(Interface): pass
class C:
spammed = 0
- __implements__ = I
+ implements(I)
class V:
def __init__(self, context, request):
self.context = context
-
+
def SPAM(self):
self.context.spammed += 1
-
class Test(PlacelessSetup, TestCase):
# Note that zope publication tests cover all of the code but callObject
@@ -52,7 +51,6 @@
pub.callObject(request, ob)
self.assertEqual(ob.spammed, 1)
-
def test_suite():
return TestSuite((
=== Zope3/src/zope/app/publication/tests/test_zopepublication.py 1.13 => 1.13.10.1 ===
--- Zope3/src/zope/app/publication/tests/test_zopepublication.py:1.13 Thu May 1 15:35:26 2003
+++ Zope3/src/zope/app/publication/tests/test_zopepublication.py Sun Jun 22 10:23:19 2003
@@ -15,7 +15,7 @@
import sys
from zope.interface.verify import verifyClass
-from zope.interface.implements import instancesOfObjectImplements
+from zope.interface import implements, classImplements, implementedBy
from zodb.db import DB
from zodb.storage.mapping import MappingStorage
@@ -44,7 +44,7 @@
from zope.publisher.base import TestRequest
from zope.publisher.browser import BrowserResponse
-from zope.proxy.context import getWrapperContext
+from zope.context import getWrapperContext
from transaction import get_transaction
from cStringIO import StringIO
@@ -86,7 +86,7 @@
PlacelessSetup.tearDown(self)
def testInterfacesVerify(self):
- for interface in instancesOfObjectImplements(ZopePublication):
+ for interface in implementedBy(ZopePublication):
verifyClass(interface, TestPublication)
class Principal:
@@ -96,7 +96,7 @@
def getDescription(self): return ''
class UnauthenticatedPrincipal(Principal):
- __implements__ = IUnauthenticatedPrincipal
+ implements(IUnauthenticatedPrincipal)
class AuthService1:
@@ -125,7 +125,7 @@
class ServiceManager:
- __implements__ = IServiceService # a dirty lie
+ implements(IServiceService) # a dirty lie
def __init__(self, auth):
self.auth = auth
@@ -180,10 +180,9 @@
def testViewOnException(self):
from zodb.interfaces import ConflictError
from zope.interface import Interface
- from zope.interface.implements import implements
class IConflictError(Interface):
pass
- implements(ConflictError, IConflictError)
+ classImplements(ConflictError, IConflictError)
setDefaultViewName(IConflictError, self.presentation_type, 'name')
view_text = 'You had a conflict error'
provideView(IConflictError, 'name', self.presentation_type,
@@ -200,13 +199,12 @@
def testNoViewOnClassicClassException(self):
from zodb.interfaces import ConflictError
from zope.interface import Interface
- from zope.interface.implements import implements
from types import ClassType
class ClassicError:
__metaclass__ = ClassType
class IClassicError(Interface):
pass
- implements(ClassicError, IClassicError)
+ classImplements(ClassicError, IClassicError)
setDefaultViewName(IClassicError, self.presentation_type, 'name')
view_text = 'You made a classic error ;-)'
provideView(IClassicError, 'name', self.presentation_type,
@@ -226,7 +224,7 @@
def testExceptionSideEffects(self):
from zope.publisher.interfaces import IExceptionSideEffects
class SideEffects:
- __implements__ = IExceptionSideEffects
+ implements(IExceptionSideEffects)
def __init__(self, exception):
self.exception = exception
def __call__(self, obj, request, exc_info):
@@ -241,10 +239,9 @@
factory = SideEffectsFactory()
from zodb.interfaces import ConflictError
from zope.interface import Interface
- from zope.interface.implements import implements
class IConflictError(Interface):
pass
- implements(ConflictError, IConflictError)
+ classImplements(ConflictError, IConflictError)
provideAdapter(IConflictError, IExceptionSideEffects, factory)
exception = ConflictError()
try: