/usr/share/pyshared/zope/publisher/tests/test_ipublication.py is in python-zope.publisher 3.12.6-2ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | ##############################################################################
#
# Copyright (c) 2001, 2002 Zope Foundation 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.
#
##############################################################################
"""IPublication Test
"""
import sys
from unittest import TestCase, main, makeSuite
from StringIO import StringIO
from zope.interface.verify import verifyObject
from zope.publisher.interfaces import IPublication
class BaseIPublicationTest(object):
# This test isn't as interesting as we'd like it to be because we
# know too little about the semantics if a particular publication
# object.
def testVerifyIPublication(self):
verifyObject(IPublication, self._Test__new())
def setUp(self):
self._request = request = self._Test__request()
self._publication = request.publication
def testgetApplication(self):
self._publication.getApplication(self._request)
class Test(BaseIPublicationTest, TestCase):
def _Test__new(self):
from zope.publisher.tests.publication import TestPublication
return TestPublication()
def _Test__request(self):
from zope.publisher.base import BaseRequest
request = BaseRequest(StringIO(''), {})
request.setTraversalStack(['Engineering', 'ZopeCorp'])
publication = self._Test__new()
request.setPublication(publication)
return request
# The following are specific to our particular stub, but might be
# good examples of tests for other implementations.
def test_afterCall(self):
self._publication.afterCall(self._request, None)
self.assertEqual(self._publication._afterCall, 1)
def test_traverseName(self):
ob = self._publication.getApplication(self._request)
ob = self._publication.traverseName(self._request, ob, 'ZopeCorp')
self.assertEqual(ob.name, 'ZopeCorp')
ob = self._publication.traverseName(self._request, ob, 'Engineering')
self.assertEqual(ob.name, 'Engineering')
def test_afterTraversal(self):
self._publication.afterTraversal(self._request, None)
self.assertEqual(self._publication._afterTraversal, 1)
def test_beforeTraversal(self):
self._publication.beforeTraversal(self._request)
self.assertEqual(self._publication._beforeTraversal, 1)
def test_callObject(self):
result = self._publication.callObject(
self._request, lambda request: 42)
self.assertEqual(result, 42)
def test_getApplication(self):
from zope.publisher.tests.publication import app
result = self._publication.getApplication(self._request)
self.assertEqual(id(result), id(app))
def test_handleException(self):
try:
raise ValueError(1)
except:
exc_info = sys.exc_info()
try:
self._publication.handleException(object, self._request, exc_info)
finally:
exc_info = 0
def test_callTraversalHooks(self):
self._publication.callTraversalHooks(self._request, None)
self.assertEqual(self._publication._callTraversalHooks, 1)
def test_suite():
return makeSuite(Test)
if __name__=='__main__':
main(defaultTest='test_suite')
|