/usr/lib/python2.7/dist-packages/zope/browserresource/tests/test_resource.py is in python-zope.browserresource 3.12.0-0ubuntu2.
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 | ##############################################################################
#
# Copyright (c) 2003 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.
#
##############################################################################
"""Unit tests for Resource
"""
import unittest
from zope import component
from zope.publisher.browser import TestRequest
import zope.component.interfaces
from zope.browserresource.resource import Resource
from zope.browserresource.tests import support
from zope.traversing.browser.interfaces import IAbsoluteURL
from zope.traversing.browser.absoluteurl import AbsoluteURL
from zope.testing import cleanup
class TestResource(support.SiteHandler, cleanup.CleanUp, unittest.TestCase):
def setUp(self):
super(TestResource, self).setUp()
component.provideAdapter(AbsoluteURL, (None, None), IAbsoluteURL)
def testGlobal(self):
req = TestRequest()
r = Resource(req)
req._vh_root = support.site
r.__parent__ = support.site
r.__name__ = 'foo'
self.assertEquals(r(), 'http://127.0.0.1/@@/foo')
r.__name__ = '++resource++foo'
self.assertEquals(r(), 'http://127.0.0.1/@@/foo')
def testGlobalInVirtualHost(self):
req = TestRequest()
req.setVirtualHostRoot(['x', 'y'])
r = Resource(req)
req._vh_root = support.site
r.__parent__ = support.site
r.__name__ = 'foo'
self.assertEquals(r(), 'http://127.0.0.1/x/y/@@/foo')
def testResourceUrl(self):
# fake IAbsoluteURL adapter
def resourceBase(site, request):
return 'http://cdn.example.com'
component.provideAdapter(
resourceBase,
(zope.component.interfaces.ISite, TestRequest),
IAbsoluteURL, 'resource')
req = TestRequest()
r = Resource(req)
req._vh_root = support.site
r.__parent__ = support.site
r.__name__ = 'foo'
self.assertEquals(r(), 'http://cdn.example.com/@@/foo')
def test_suite():
return unittest.makeSuite(TestResource)
|