[Zope3-checkins] CVS: Zope3/src/zope/app/publisher/browser/tests -
test_icondirective.py:1.11 test_resource.py:1.6
Jim Fulton
jim at zope.com
Sun Sep 21 13:32:43 EDT 2003
Update of /cvs-repository/Zope3/src/zope/app/publisher/browser/tests
In directory cvs.zope.org:/tmp/cvs-serv14568/src/zope/app/publisher/browser/tests
Modified Files:
test_icondirective.py test_resource.py
Log Message:
Resources now include host information in generated resource urls.
=== Zope3/src/zope/app/publisher/browser/tests/test_icondirective.py 1.10 => 1.11 ===
--- Zope3/src/zope/app/publisher/browser/tests/test_icondirective.py:1.10 Sun Aug 17 02:07:35 2003
+++ Zope3/src/zope/app/publisher/browser/tests/test_icondirective.py Sun Sep 21 13:32:42 2003
@@ -30,6 +30,8 @@
from zope.component import queryView, getView, getResource
from zope.configuration.exceptions import ConfigurationError
from zope.interface import implements
+from zope.app.interfaces.services.service import ISite
+from zope.app.interfaces.traversing import IContainmentRoot
import zope.app.publisher.browser
@@ -45,9 +47,10 @@
request = TestRequest(IBrowserPresentation)
class Ob:
- implements(IC)
+ implements(IC, ISite, IContainmentRoot)
ob = Ob()
+request._vh_root = ob
def defineCheckers():
# define the appropriate checker for a FileResource for these tests
@@ -82,14 +85,12 @@
rname = 'zope-component-tests-views-IC-zmi_icon.gif'
self.assertEqual(
view(),
- '<img src="/@@/%s" alt="IC" width="16" height="16" border="0" />'
+ '<img src="http://127.0.0.1/@@/%s" alt="IC" '
+ 'width="16" height="16" border="0" />'
% rname)
resource = getResource(ob, rname, request)
- # Resources come ready-wrapped from the factory
- #resource = ProxyFactory(resource)
-
self.assertRaises(Forbidden, getattr, resource, '_testData')
resource = removeAllProxies(resource)
self.assertEqual(resource._testData(), open(path, 'rb').read())
@@ -115,7 +116,8 @@
rname = "zmi_icon_res"
self.assertEqual(
view(),
- '<img src="/@@/%s" alt="IC" width="16" height="16" border="0" />'
+ '<img src="http://127.0.0.1/@@/%s" alt="IC" width="16" '
+ 'height="16" border="0" />'
% rname)
resource = getResource(ob, rname, request)
=== Zope3/src/zope/app/publisher/browser/tests/test_resource.py 1.5 => 1.6 ===
--- Zope3/src/zope/app/publisher/browser/tests/test_resource.py:1.5 Fri Aug 15 20:43:51 2003
+++ Zope3/src/zope/app/publisher/browser/tests/test_resource.py Sun Sep 21 13:32:42 2003
@@ -16,35 +16,38 @@
$Id$
"""
import unittest
-from zope.app.context import ContextWrapper
from zope.app.publisher.browser.resource import Resource
-from zope.component.interfaces import IResourceService
from zope.interface import implements
from zope.publisher.browser import TestRequest
+from zope.app.interfaces.services.service import ISite
+from zope.app.tests.placelesssetup import PlacelessSetup
+from zope.app.interfaces.traversing import IContainmentRoot
-class Service:
- implements(IResourceService)
+class Site:
+ implements(ISite, IContainmentRoot)
-class TestResource(unittest.TestCase):
+site = Site()
+
+class TestResource(PlacelessSetup, unittest.TestCase):
def testGlobal(self):
req = TestRequest()
- r = ContextWrapper(Resource(req), Service(), name="foo")
- self.assertEquals(r(), '/@@/foo')
- r = ContextWrapper(Resource(req), Service(), name="++resource++foo")
- self.assertEquals(r(), '/@@/foo')
-
- def testGlobalWithSkin(self):
- req = TestRequest()
- req._presentation_skin = 'bar'
- r = ContextWrapper(Resource(req), Service(), name="foo")
- self.assertEquals(r(), '/++skin++bar/@@/foo')
+ r = Resource(req)
+ req._vh_root = site
+ r.__parent__ = 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 = ContextWrapper(Resource(req), Service(), name="foo")
- self.assertEquals(r(), '/x/y/@@/foo')
+ r = Resource(req)
+ req._vh_root = site
+ r.__parent__ = site
+ r.__name__ = 'foo'
+ self.assertEquals(r(), 'http://127.0.0.1/x/y/@@/foo')
def test_suite():
More information about the Zope3-Checkins
mailing list