Skip to content

Commit

Permalink
Fixed a couple functional tests.
Browse files Browse the repository at this point in the history
Tried to remove the service terminology from the code as much as 
possible.
  • Loading branch information
strichter committed Jan 12, 2005
1 parent 34b6e98 commit c2120cc
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 12 deletions.
49 changes: 49 additions & 0 deletions ftp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
"""Test FTP Publication.
$Id$
"""
__docformat__ = 'restructuredtext'
from zope.publisher.interfaces import NotFound
from zope.publisher.publish import mapply

from zope.app import zapi
from zope.app.publication.zopepublication import ZopePublication



class FTPPublication(ZopePublication):
"""The Publication will do all the work for the FTP"""

def callObject(self, request, ob):
method = request['command']
view = zapi.queryMultiAdapter((ob, request), name=method, default=self)
if view is self:
raise NotFound(ob, method, request)

return mapply(getattr(view, method), (), request)

def annotateTransaction(self, txn, request, ob):
txn = super(FTPPublication, self).annotateTransaction(txn, request, ob)
request_info = [request['command']]
path = request.get('path', '')
if path:
request_info.append(path)
name = request.get('name', '')
if name:
request_info.append(name)
request_info = ' '.join(request_info)
txn.setExtendedInfo('request_info', request_info)
return txn
2 changes: 1 addition & 1 deletion tests/test_browserpublication.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def __init__(self, context, request): pass
ob2 = pub.traverseName(r, ob, '@@spam')
self.assertEqual(ob2.__class__, V)

def testTraverseNameServices(self):
def testTraverseNameSiteManager(self):
pub = self.klass(self.db)
class C(object):
def getSiteManager(self):
Expand Down
2 changes: 0 additions & 2 deletions tests/test_httpfactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
from zope.publisher.browser import BrowserRequest
from zope.publisher.http import HTTPRequest
from zope.publisher.xmlrpc import XMLRPCRequest
from zope.component.interfaces import IAdapterService
from zope.component.adapter import GlobalAdapterService
from zope.component.tests.placelesssetup import PlacelessSetup

from zope.app.publication.httpfactory import HTTPPublicationRequestFactory
Expand Down
2 changes: 1 addition & 1 deletion tests/test_xmlrpcpublication.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def __init__(self, context, request):
self.assertEqual(removeAllProxies(ob2).__class__, V)


def testTraverseNameServices(self):
def testTraverseNameSiteManager(self):
pub = self.klass(self.db)
class C(object):
def getSiteManager(self):
Expand Down
8 changes: 4 additions & 4 deletions tests/test_zopepublication.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def testHandlingSystemErrors(self):
' Error while reporting an error to the Error Reporting utility')

# Here we got a single log record, because we havdn't
# installed an error reporting service. That's OK.
# installed an error reporting utility. That's OK.

handler.uninstall()
self.out.seek(0)
Expand Down Expand Up @@ -254,7 +254,7 @@ def __call__(self):

# Now, since the view was a system error view, we should have
# a log entry for the E2 error (as well as the missing
# error reporting service).
# error reporting utility).
self.assertEqual(
str(handler),
'SiteError ERROR\n'
Expand Down Expand Up @@ -354,7 +354,7 @@ def testAbortOrCommitTransaction(self):
self.assert_(txn is not get_transaction())

def testAbortTransactionWithErrorReportingUtility(self):
# provide our fake error logging service
# provide our fake error reporting utility
sm = zapi.getGlobalSiteManager()
sm.provideUtility(IErrorReportingUtility, ErrorReportingUtility())

Expand All @@ -373,7 +373,7 @@ class FooError(Exception):
new_txn_info = self.db.undoInfo()[0]
self.assertEqual(last_txn_info, new_txn_info)

# instead, we expect a message in our logging service
# instead, we expect a message in our logging utility
error_log = zapi.getUtility(IErrorReportingUtility)
self.assertEqual(len(error_log.exceptions), 1)
error_info, request = error_log.exceptions[0]
Expand Down
7 changes: 3 additions & 4 deletions zopepublication.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def _maybePlacefullyAuthenticate(self, request, ob):
return

if not ISite.providedBy(ob):
# We won't find an authentication service here, so give up.
# We won't find an authentication utility here, so give up.
return

sm = removeSecurityProxy(ob).getSiteManager()
Expand All @@ -100,7 +100,7 @@ def _maybePlacefullyAuthenticate(self, request, ob):
# No auth utility here
return

# Try to authenticate against the auth service
# Try to authenticate against the auth utility
principal = auth.authenticate(request)
if principal is None:
principal = auth.unauthenticatedPrincipal()
Expand Down Expand Up @@ -186,8 +186,7 @@ def annotateTransaction(self, txn, request, ob):
# Views are made children of their contexts, but that
# doesn't necessarily mean that we can fully resolve the
# path. E.g. the family tree of a resource cannot be
# resolved completely, as the presentation service is a
# dead end.
# resolved completely, as the site manager is a dead end.
try:
path = locatable.getPath()
except (AttributeError, TypeError):
Expand Down

0 comments on commit c2120cc

Please sign in to comment.