[Zope3-checkins] CVS: Zope3/src/zope/app/publisher/browser/tests - test_resource.py:1.1 test_icondirective.py:1.3

Albertas Agejevas alga@codeworks.lt
Tue, 15 Apr 2003 08:25:04 -0400


Update of /cvs-repository/Zope3/src/zope/app/publisher/browser/tests
In directory cvs.zope.org:/tmp/cvs-serv11793/src/zope/app/publisher/browser/tests

Modified Files:
	test_icondirective.py 
Added Files:
	test_resource.py 
Log Message:
Added virtual hosting support to resources, complete with unit tests
and functional tests.



=== Added File Zope3/src/zope/app/publisher/browser/tests/test_resource.py ===
##############################################################################
#
# Copyright (c) 2003 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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

$Id: test_resource.py,v 1.1 2003/04/15 12:24:33 alga Exp $
"""

import unittest
from zope.publisher.browser import TestRequest
from zope.proxy.context import ContextWrapper

class TestResource(unittest.TestCase):

    def testGlobal(self):
        from zope.app.publisher.browser.resource import Resource
        req = TestRequest()
        r = ContextWrapper(Resource(req), None, name="foo")
        self.assertEquals(r(), '/@@/foo')
        r = ContextWrapper(Resource(req), None, name="++resource++foo")
        self.assertEquals(r(), '/@@/foo')

    def testGlobalWithSkin(self):
        from zope.app.publisher.browser.resource import Resource
        req = TestRequest()
        req._presentation_skin = 'bar'
        r = ContextWrapper(Resource(req), None, name="foo")
        self.assertEquals(r(), '/++skin++bar/@@/foo')

    def testGlobalInVirtualHost(self):
        from zope.app.publisher.browser.resource import Resource
        req = TestRequest()
        req.setApplicationNames(['x', 'y'])
        r = ContextWrapper(Resource(req), None, name="foo")
        self.assertEquals(r(), '/x/y/@@/foo')


def test_suite():
    suite = unittest.TestSuite()
    suite.addTest(unittest.makeSuite(TestResource))
    return suite


if __name__ == '__main__':
    unittest.main()


=== Zope3/src/zope/app/publisher/browser/tests/test_icondirective.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/publisher/browser/tests/test_icondirective.py:1.2	Wed Dec 25 09:13:10 2002
+++ Zope3/src/zope/app/publisher/browser/tests/test_icondirective.py	Tue Apr 15 08:24:33 2003
@@ -24,7 +24,7 @@
 from zope.proxy.introspection import removeAllProxies
 from zope.app.tests.placelesssetup import PlacelessSetup
 from zope.configuration.xmlconfig import xmlconfig, XMLConfig
-from zope.component.tests.request import Request
+from zope.publisher.browser import TestRequest
 from zope.component.tests.views import IC
 from zope.publisher.interfaces.browser import IBrowserPresentation
 from zope.component import queryView, getView, getResource
@@ -42,7 +42,7 @@
    </zopeConfigure>"""
 
 
-request = Request(IBrowserPresentation)
+request = TestRequest(IBrowserPresentation)
 
 class Ob:
     __implements__ = IC