[Zope3-checkins] CVS: Zope3/src/zope/app/publisher/browser/tests - __init__.py:1.2 templateclass.py:1.2 test.gif:1.2 test.pt:1.2 test.txt:1.2 test2.pt:1.2 test3.pt:1.2 test_directives.py:1.2 test_fileresource.py:1.2 test_globalbrowsermenuservice.py:1.2 test_globalbrowsermenuservicedirectives.py:1.2 test_icondirective.py:1.2 test_resources.py:1.2 testi18nfileresource.py:1.2

Jim Fulton jim@zope.com
Wed, 25 Dec 2002 09:14:11 -0500


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

Added Files:
	__init__.py templateclass.py test.gif test.pt test.txt 
	test2.pt test3.pt test_directives.py test_fileresource.py 
	test_globalbrowsermenuservice.py 
	test_globalbrowsermenuservicedirectives.py 
	test_icondirective.py test_resources.py 
	testi18nfileresource.py 
Log Message:
Grand renaming:

- Renamed most files (especially python modules) to lower case.

- Moved views and interfaces into separate hierarchies within each
  project, where each top-level directory under the zope package
  is a separate project.

- Moved everything to src from lib/python.

  lib/python will eventually go away. I need access to the cvs
  repository to make this happen, however.

There are probably some bits that are broken. All tests pass
and zope runs, but I haven't tried everything. There are a number
of cleanups I'll work on tomorrow.



=== Zope3/src/zope/app/publisher/browser/tests/__init__.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:11 2002
+++ Zope3/src/zope/app/publisher/browser/tests/__init__.py	Wed Dec 25 09:13:10 2002
@@ -0,0 +1,2 @@
+#
+# This file is necessary to make this directory a package.


=== Zope3/src/zope/app/publisher/browser/tests/templateclass.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:11 2002
+++ Zope3/src/zope/app/publisher/browser/tests/templateclass.py	Wed Dec 25 09:13:10 2002
@@ -0,0 +1,2 @@
+class templateclass:
+    def data(self): return 42


=== Zope3/src/zope/app/publisher/browser/tests/test.gif 1.1 => 1.2 ===
  <Binary-ish file>

=== Zope3/src/zope/app/publisher/browser/tests/test.pt 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:11 2002
+++ Zope3/src/zope/app/publisher/browser/tests/test.pt	Wed Dec 25 09:13:10 2002
@@ -0,0 +1 @@
+<html><body><p>test</p></body></html>


=== Zope3/src/zope/app/publisher/browser/tests/test.txt 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:11 2002
+++ Zope3/src/zope/app/publisher/browser/tests/test.txt	Wed Dec 25 09:13:10 2002
@@ -0,0 +1,2 @@
+test
+data


=== Zope3/src/zope/app/publisher/browser/tests/test2.pt 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:11 2002
+++ Zope3/src/zope/app/publisher/browser/tests/test2.pt	Wed Dec 25 09:13:10 2002
@@ -0,0 +1 @@
+<html><body><p tal:content="view/data">test</p></body></html>


=== Zope3/src/zope/app/publisher/browser/tests/test3.pt 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:11 2002
+++ Zope3/src/zope/app/publisher/browser/tests/test3.pt	Wed Dec 25 09:13:10 2002
@@ -0,0 +1 @@
+<html><body><p tal:content="view/action">test</p></body></html>


=== Zope3/src/zope/app/publisher/browser/tests/test_directives.py 1.1 => 1.2 === (595/695 lines abridged)
--- /dev/null	Wed Dec 25 09:14:11 2002
+++ Zope3/src/zope/app/publisher/browser/tests/test_directives.py	Wed Dec 25 09:13:10 2002
@@ -0,0 +1,692 @@
+##############################################################################
+#
+# 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.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.
+#
+##############################################################################
+
+import os
+import unittest
+from cStringIO import StringIO
+
+from zope.configuration.xmlconfig import xmlconfig, XMLConfig
+from zope.configuration.exceptions import ConfigurationError
+from zope.component.tests.views import IC, V1, VZMI, R1, RZMI
+from zope.component import getView, queryView, queryResource
+from zope.component import getDefaultViewName, getResource
+from zope.app.tests.placelesssetup import PlacelessSetup
+from zope.security.proxy import ProxyFactory
+from zope.proxy.introspection import removeAllProxies
+import zope.configuration
+
+from zope.component.tests.request import Request
+
+from zope.publisher.interfaces.browser import IBrowserPresentation
+
+from zope.app.publisher.browser.i18nfileresource import I18nFileResource
+
+import zope.app.publisher.browser
+
+tests_path = os.path.join(
+    os.path.split(zope.app.publisher.browser.__file__)[0],
+    'tests')
+
+template = """<zopeConfigure
+   xmlns='http://namespaces.zope.org/zope'
+   xmlns:browser='http://namespaces.zope.org/browser'>
+   %s
+   </zopeConfigure>"""
+
+request = Request(IBrowserPresentation)

[-=- -=- -=- 595 lines omitted -=- -=- -=-]

+        #newSecurityManager('someuser')
+
+        v = getView(ob, 'xxx.html', request)
+        v = ProxyFactory(v)
+        self.assertRaises(Exception, v)
+
+        v = getView(ob, 'index.html', request)
+        v = ProxyFactory(v)
+        self.assertEqual(v().strip(), '<html><body><p>test</p></body></html>')
+
+
+    def testtemplateNoName(self):
+        path = os.path.join(tests_path, 'test.pt')
+        self.assertRaises(
+            ConfigurationError,
+            xmlconfig,
+            StringIO(template %
+            """
+            <browser:view
+                  template="%s"
+                  for="zope.component.tests.views.IC"
+                  />
+            """ % path
+            ))
+
+    def testtemplateAndPage(self):
+        path = os.path.join(tests_path, 'test.pt')
+        self.assertRaises(
+            ConfigurationError,
+            xmlconfig,
+            StringIO(template %
+            """
+            <browser:view
+                  name="index.html"
+                  template="%s"
+                  for="zope.component.tests.views.IC"
+                  >
+               <browser:page name="foo.html" attribute="index" />
+            </browser:view>
+            """ % path
+            ))
+
+
+
+def test_suite():
+    loader=unittest.TestLoader()
+    return loader.loadTestsFromTestCase(Test)
+
+if __name__=='__main__':
+    unittest.TextTestRunner().run(test_suite())


=== Zope3/src/zope/app/publisher/browser/tests/test_fileresource.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:11 2002
+++ Zope3/src/zope/app/publisher/browser/tests/test_fileresource.py	Wed Dec 25 09:13:10 2002
@@ -0,0 +1,110 @@
+##############################################################################
+#
+# 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.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.
+#
+##############################################################################
+"""
+
+Revision information:
+$Id$
+"""
+
+from unittest import TestCase, TestSuite, main, makeSuite
+
+import os
+
+from zope.exceptions import NotFoundError
+
+from zope.app.tests.placelesssetup import PlacelessSetup
+from zope.component.resource import provideResource
+from zope.component.adapter import provideAdapter
+from zope.proxy.introspection import removeAllProxies
+
+from zope.interfaces.i18n import IUserPreferredCharsets
+
+from zope.publisher.http import IHTTPRequest
+from zope.publisher.http import HTTPCharsets
+from zope.publisher.browser import TestRequest
+
+from zope.app.publisher.browser.fileresource import FileResourceFactory
+from zope.app.publisher.browser.fileresource import ImageResourceFactory
+import zope.app.publisher.browser.tests as p
+
+test_directory = os.path.split(p.__file__)[0]
+
+class Test(PlacelessSetup, TestCase):
+
+    def setUp(self):
+        PlacelessSetup.setUp(self)
+        provideAdapter(IHTTPRequest, IUserPreferredCharsets, HTTPCharsets)
+
+    def testNoTraversal(self):
+
+        path = os.path.join(test_directory, 'test.txt')
+        resource = FileResourceFactory(path)(TestRequest())
+        resource = removeAllProxies(resource)
+        self.assertRaises(NotFoundError,
+                          resource.publishTraverse,
+                          resource.request,
+                          '_testData')
+
+    def testFileGET(self):
+
+        path = os.path.join(test_directory, 'test.txt')
+
+        resource = FileResourceFactory(path)(TestRequest())
+        resource = removeAllProxies(resource)
+        self.assertEqual(resource.GET(), open(path, 'rb').read())
+
+        response = resource.request.response
+        self.assertEqual(response.getHeader('Content-Type'), 'text/plain')
+
+    def testFileHEAD(self):
+
+        path = os.path.join(test_directory, 'test.txt')
+        resource = FileResourceFactory(path)(TestRequest())
+        resource = removeAllProxies(resource)
+
+        self.assertEqual(resource.HEAD(), '')
+
+        response = resource.request.response
+        self.assertEqual(response.getHeader('Content-Type'), 'text/plain')
+
+    def testImageGET(self):
+
+        path = os.path.join(test_directory, 'test.gif')
+
+        resource = ImageResourceFactory(path)(TestRequest())
+        resource = removeAllProxies(resource)
+
+        self.assertEqual(resource.GET(), open(path, 'rb').read())
+
+        response = resource.request.response
+        self.assertEqual(response.getHeader('Content-Type'), 'image/gif')
+
+    def testImageHEAD(self):
+
+        path = os.path.join(test_directory, 'test.gif')
+        resource = ImageResourceFactory(path)(TestRequest())
+        resource = removeAllProxies(resource)
+
+        self.assertEqual(resource.HEAD(), '')
+
+        response = resource.request.response
+        self.assertEqual(response.getHeader('Content-Type'), 'image/gif')
+
+
+
+def test_suite():
+    return makeSuite(Test)
+
+if __name__=='__main__':
+    main(defaultTest='test_suite')


=== Zope3/src/zope/app/publisher/browser/tests/test_globalbrowsermenuservice.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:11 2002
+++ Zope3/src/zope/app/publisher/browser/tests/test_globalbrowsermenuservice.py	Wed Dec 25 09:13:10 2002
@@ -0,0 +1,122 @@
+##############################################################################
+#
+# Copyright (c) 2002 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.
+#
+##############################################################################
+"""XXX short summary goes here.
+
+XXX longer description goes here.
+
+$Id$
+"""
+
+from unittest import TestCase, TestSuite, main, makeSuite
+from zope.publisher.interfaces.browser import IBrowserPublisher
+from zope.exceptions import Forbidden, Unauthorized, DuplicationError
+from zope.interface import Interface
+from zope.publisher.browser import TestRequest
+from zope.app.tests.placelesssetup import PlacelessSetup
+
+class I1(Interface): pass
+class I11(I1): pass
+class I12(I1): pass
+class I111(I11): pass
+
+class X:
+    __implements__ = IBrowserPublisher, I111
+
+    def f(self): pass
+
+    def browserDefault(self, r): return self, ()
+    def publishTraverse(self, request, name):
+        if name[:1] == 'f':
+            raise Forbidden, name
+        if name[:1] == 'u':
+            raise Unauthorized, name
+        return self.f
+
+
+class Test(PlacelessSetup, TestCase):
+
+    def __reg(self):
+        from zope.app.publisher.browser.globalbrowsermenuservice \
+             import GlobalBrowserMenuService
+
+        r = GlobalBrowserMenuService()
+        return r
+
+    def testDup(self):
+        r = self.__reg()
+        r.menu('test_id', 'test menu')
+        self.assertRaises(DuplicationError, r.menu, 'test_id', 'test menu')
+
+    def test(self):
+        r = self.__reg()
+        r.menu('test_id', 'test menu')
+        r.menuItem('test_id', Interface, 'a1', 't1', 'd1')
+        r.menuItem('test_id', I1, 'a2', 't2', 'd2')
+        r.menuItem('test_id', I11, 'a3', 't3', 'd3', 'context')
+        r.menuItem('test_id', I11, 'a4', 't4', 'd4', 'not:context')
+        r.menuItem('test_id', I111, 'a5', 't5', 'd5')
+        r.menuItem('test_id', I111, 'a6', 't6', 'd6')
+        r.menuItem('test_id', I111, 'f7', 't7', 'd7')
+        r.menuItem('test_id', I111, 'u8', 't8', 'd8')
+        r.menuItem('test_id', I12, 'a9', 't9', 'd9')
+
+        menu = r.getMenu('test_id', X(), TestRequest())
+
+        def d(n):
+            return {'action': "a%s" % n,
+                    'title':  "t%s" % n,
+                    'description':  "d%s" % n,
+                    'selected': ''
+                    }
+
+        self.assertEqual(list(menu), [d(5), d(6), d(3), d(2), d(1)])
+
+    def test_no_dups(self):
+        r = self.__reg()
+        r.menu('test_id', 'test menu')
+        r.menuItem('test_id', Interface, 'a1', 't1', 'd1')
+        r.menuItem('test_id', Interface, 'a12', 't2', 'd12')
+        r.menuItem('test_id', I1, 'a2', 't2', 'd2')
+        r.menuItem('test_id', I1, 'a23', 't3', 'd23')
+        r.menuItem('test_id', I1, 'a24', 't4', 'd24')
+        r.menuItem('test_id', I11, 'a3', 't3', 'd3', 'context')
+        r.menuItem('test_id', I11, 'a4', 't4', 'd4', 'not:context')
+        r.menuItem('test_id', I111, 'a5', 't5', 'd5')
+        r.menuItem('test_id', I111, 'a6', 't6', 'd6')
+        r.menuItem('test_id', I111, 'f7', 't7', 'd7')
+        r.menuItem('test_id', I111, 'u8', 't8', 'd8')
+        r.menuItem('test_id', I12, 'a9', 't9', 'd9')
+
+        menu = r.getMenu('test_id', X(), TestRequest())
+
+        def d(n):
+            return {'action': "a%s" % n,
+                    'title':  "t%s" % n,
+                    'description':  "d%s" % n,
+                    'selected': ''}
+
+        self.assertEqual(list(menu), [d(5), d(6), d(3), d(2), d(1)])
+
+    def testEmpty(self):
+        r = self.__reg()
+        r.menu('test_id', 'test menu')
+        menu = r.getMenu('test_id', X(), TestRequest())
+        self.assertEqual(list(menu), [])
+
+
+def test_suite():
+    return makeSuite(Test)
+
+if __name__=='__main__':
+    main(defaultTest='test_suite')


=== Zope3/src/zope/app/publisher/browser/tests/test_globalbrowsermenuservicedirectives.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:11 2002
+++ Zope3/src/zope/app/publisher/browser/tests/test_globalbrowsermenuservicedirectives.py	Wed Dec 25 09:13:10 2002
@@ -0,0 +1,114 @@
+##############################################################################
+#
+# Copyright (c) 2002 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.
+#
+##############################################################################
+"""XXX short summary goes here.
+
+XXX longer description goes here.
+
+$Id$
+"""
+
+from StringIO import StringIO
+from unittest import TestCase, TestSuite, main, makeSuite
+
+from zope.configuration.xmlconfig import xmlconfig, XMLConfig
+from zope.publisher.interfaces.browser import IBrowserPublisher
+from zope.publisher.browser import TestRequest
+from zope.app.tests.placelesssetup import PlacelessSetup
+import zope.configuration
+
+import zope.app.publisher.browser
+
+template = """<zopeConfigure
+   xmlns='http://namespaces.zope.org/zope'
+   xmlns:browser='http://namespaces.zope.org/browser'>
+   %s
+   </zopeConfigure>"""
+
+class Test(PlacelessSetup, TestCase):
+
+    def setUp(self):
+        PlacelessSetup.setUp(self)
+        XMLConfig('metameta.zcml', zope.configuration)()
+        XMLConfig('meta.zcml', zope.app.publisher.browser)()
+
+    def test(self):
+        from zope.app.publisher.browser.globalbrowsermenuservice \
+             import globalBrowserMenuService
+
+        xmlconfig(StringIO(template % (
+            """
+            <browser:menu id="test_id" title="test menu" />
+
+            <browser:menuItems menu="test_id" for="zope.interface.Interface">
+              <browser:menuItem action="a1" title="t1" />
+            </browser:menuItems>
+
+            <browser:menuItems menu="test_id"
+              for="
+           zope.app.publisher.browser.tests.test_globalbrowsermenuservice.I1
+              ">
+              <browser:menuItem action="a2" title="t2" />
+            </browser:menuItems>
+
+            <browser:menuItems menu="test_id"
+              for="
+           zope.app.publisher.browser.tests.test_globalbrowsermenuservice.I11
+              ">
+              <browser:menuItem action="a3" title="t3" filter="context" />
+              <browser:menuItem action="a4" title="t4" filter="not:context" />
+            </browser:menuItems>
+
+            <browser:menuItems menu="test_id"
+              for="
+           zope.app.publisher.browser.tests.test_globalbrowsermenuservice.I111
+              ">
+              <browser:menuItem action="a5" title="t5" />
+              <browser:menuItem action="a6" title="t6" />
+              <browser:menuItem action="f7" title="t7" />
+              <browser:menuItem action="u8" title="t8" />
+            </browser:menuItems>
+
+            <browser:menuItems menu="test_id"
+              for="
+           zope.app.publisher.browser.tests.test_globalbrowsermenuservice.I12
+              ">
+              <browser:menuItem action="a9" title="t9" />
+            </browser:menuItems>
+            """)))
+
+
+        from zope.app.publisher.browser.tests.test_globalbrowsermenuservice \
+             import X
+
+        menu = globalBrowserMenuService.getMenu('test_id', X(), TestRequest())
+
+        def d(n):
+            return {'action': "a%s" % n,
+                    'title':  "t%s" % n,
+                    'description':  "",
+                    'selected': ''
+                    }
+
+        self.assertEqual(list(menu), [d(5), d(6), d(3), d(2), d(1)])
+
+        first = globalBrowserMenuService.getFirstMenuItem(
+            'test_id', X(), TestRequest())
+
+        self.assertEqual(first, d(5))
+
+def test_suite():
+    return makeSuite(Test)
+
+if __name__=='__main__':
+    main(defaultTest='test_suite')


=== Zope3/src/zope/app/publisher/browser/tests/test_icondirective.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:11 2002
+++ Zope3/src/zope/app/publisher/browser/tests/test_icondirective.py	Wed Dec 25 09:13:10 2002
@@ -0,0 +1,164 @@
+##############################################################################
+#
+# 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.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.
+#
+##############################################################################
+"""
+
+Revision information:
+$Id$
+"""
+import os
+from StringIO import StringIO
+from unittest import TestCase, main, makeSuite
+
+from zope.exceptions import Forbidden
+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.component.tests.views import IC
+from zope.publisher.interfaces.browser import IBrowserPresentation
+from zope.component import queryView, getView, getResource
+from zope.security.proxy import ProxyFactory
+from zope.configuration.exceptions import ConfigurationError
+import zope.configuration
+
+import zope.app.publisher.browser
+
+template = """<zopeConfigure
+   xmlns='http://namespaces.zope.org/zope'
+   xmlns:browser='http://namespaces.zope.org/browser'
+   >
+   %s
+   </zopeConfigure>"""
+
+
+request = Request(IBrowserPresentation)
+
+class Ob:
+    __implements__ = IC
+
+ob = Ob()
+
+def defineCheckers():
+    # define the appropriate checker for a FileResource for these tests
+    from zope.app.security.protectclass import protectName
+    from zope.app.publisher.browser.fileresource import FileResource
+    protectName(FileResource, '__call__', 'zope.Public')
+
+
+class Test(PlacelessSetup, TestCase):
+
+    def setUp(self):
+        PlacelessSetup.setUp(self)
+        XMLConfig('metameta.zcml', zope.configuration)()
+        XMLConfig('meta.zcml', zope.app.publisher.browser)()
+        defineCheckers()
+
+    def test(self):
+        self.assertEqual(queryView(ob, 'zmi_icon', request), None)
+
+        import zope.app.publisher.browser.tests as p
+        path = os.path.split(p.__file__)[0]
+        path = os.path.join(path, 'test.gif')
+
+        xmlconfig(StringIO(template % (
+            """
+            <browser:icon name="zmi_icon"
+                      for="zope.component.tests.views.IC"
+                      file="%s" />
+            """ % path
+            )))
+
+        view = getView(ob, 'zmi_icon', request)
+        rname = 'zope-component-tests-views-IC-zmi_icon.gif'
+        self.assertEqual(
+            view(),
+            '<img src="/@@/%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())
+
+    def testResource(self):
+        self.assertEqual(queryView(ob, 'zmi_icon', request), None)
+
+        import zope.app.publisher.browser.tests as p
+        path = os.path.split(p.__file__)[0]
+        path = os.path.join(path, 'test.gif')
+
+        xmlconfig(StringIO(template % (
+            """
+            <browser:resource name="zmi_icon_res"
+                      image="%s" />
+            <browser:icon name="zmi_icon"
+                      for="zope.component.tests.views.IC"
+                      resource="zmi_icon_res" />
+            """ % path
+            )))
+
+        view = getView(ob, 'zmi_icon', request)
+        rname = "zmi_icon_res"
+        self.assertEqual(
+            view(),
+            '<img src="/@@/%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())
+
+    def testResourceErrors(self):
+        self.assertEqual(queryView(ob, 'zmi_icon', request), None)
+
+        import zope.app.publisher.browser.tests as p
+        path = os.path.split(p.__file__)[0]
+        path = os.path.join(path, 'test.gif')
+
+        config = StringIO(template % (
+            """
+            <browser:resource name="zmi_icon_res"
+                      image="%s" />
+            <browser:icon name="zmi_icon"
+                      for="zope.component.tests.views.IC"
+                      file="%s"
+                      resource="zmi_icon_res" />
+            """ % (path, path)
+            ))
+        self.assertRaises(ConfigurationError, xmlconfig, config)
+
+        config = StringIO(template % (
+            """
+            <browser:icon name="zmi_icon"
+                      for="zope.component.tests.views.IC"
+                      />
+            """
+            ))
+        self.assertRaises(ConfigurationError, xmlconfig, config)
+
+
+def test_suite():
+    return makeSuite(Test)
+
+if __name__=='__main__':
+    main(defaultTest='test_suite')


=== Zope3/src/zope/app/publisher/browser/tests/test_resources.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:11 2002
+++ Zope3/src/zope/app/publisher/browser/tests/test_resources.py	Wed Dec 25 09:13:10 2002
@@ -0,0 +1,69 @@
+##############################################################################
+#
+# 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.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.
+#
+##############################################################################
+"""
+
+Revision information:
+$Id$
+"""
+
+from unittest import TestCase, TestSuite, main, makeSuite
+
+from zope.app.tests.placelesssetup import PlacelessSetup
+from zope.component.resource import provideResource
+from zope.component.adapter import provideAdapter
+
+from zope.interfaces.i18n import IUserPreferredCharsets
+
+from zope.publisher.http import IHTTPRequest
+from zope.publisher.http import HTTPCharsets
+from zope.publisher.browser import TestRequest
+from zope.publisher.interfaces.browser import IBrowserView
+
+class Test(PlacelessSetup, TestCase):
+
+    def setUp(self):
+        PlacelessSetup.setUp(self)
+        provideAdapter(IHTTPRequest, IUserPreferredCharsets, HTTPCharsets)
+
+
+    def test(self):
+        from zope.app.publisher.browser.resources import Resources
+        request = TestRequest()
+
+        class Resource:
+            def __init__(self, request): pass
+            def __call__(self): return 42
+
+        provideResource('test', IBrowserView, Resource)
+        view = Resources(None, request)
+        resource = view.publishTraverse(request, 'test')
+        self.assertEqual(resource(), 42)
+
+    def testNotFound(self):
+        from zope.app.publisher.browser.resources import Resources
+        from zope.exceptions import NotFoundError
+        request = TestRequest()
+        view = Resources(None, request)
+        self.assertRaises(NotFoundError,
+                          view.publishTraverse,
+                          request, 'test'
+                          )
+
+
+
+def test_suite():
+    return makeSuite(Test)
+
+if __name__=='__main__':
+    main(defaultTest='test_suite')


=== Zope3/src/zope/app/publisher/browser/tests/testi18nfileresource.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:11 2002
+++ Zope3/src/zope/app/publisher/browser/tests/testi18nfileresource.py	Wed Dec 25 09:13:10 2002
@@ -0,0 +1,160 @@
+##############################################################################
+#
+# 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.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.
+#
+##############################################################################
+"""
+
+Revision information:
+$Id$
+"""
+
+from unittest import TestSuite, main, makeSuite
+
+import os
+
+from zope.exceptions import NotFoundError
+
+from zope.app.tests.placelesssetup import PlacelessSetup
+from zope.component.resource import provideResource
+from zope.component.adapter import provideAdapter
+
+from zope.interfaces.i18n import IUserPreferredCharsets
+from zope.interfaces.i18n import IUserPreferredLanguages
+
+from zope.publisher.http import IHTTPRequest
+from zope.publisher.http import HTTPCharsets
+from zope.publisher.browser import BrowserLanguages
+from zope.publisher.browser import TestRequest
+
+from zope.app.publisher.browser.i18nfileresource import I18nFileResource
+from zope.app.publisher.browser.i18nfileresource import I18nFileResourceFactory
+from zope.app.publisher.fileresource import File, Image
+import zope.app.publisher.browser.tests as p
+
+from zope.app.component.metaconfigure import \
+     provideService, managerHandler
+from zope.interfaces.i18n import INegotiator
+from zope.i18n.negotiator import negotiator
+
+from zope.i18n.tests.testii18naware import TestII18nAware
+
+test_directory = os.path.split(p.__file__)[0]
+
+
+class Test(PlacelessSetup, TestII18nAware):
+
+    def setUp(self):
+        PlacelessSetup.setUp(self)
+        TestII18nAware.setUp(self)
+        provideAdapter(IHTTPRequest, IUserPreferredCharsets, HTTPCharsets)
+        provideAdapter(IHTTPRequest, IUserPreferredLanguages, BrowserLanguages)
+        # Setup the negotiator service registry entry
+        managerHandler('defineService', 'LanguageNegotiation', INegotiator)
+        provideService('LanguageNegotiation', negotiator, 'zope.Public')
+
+
+    def _createObject(self):
+        obj = I18nFileResource({'en':None, 'lt':None, 'fr':None},
+                               TestRequest(), 'fr')
+        return obj
+
+
+    def _createDict(self, filename1='test.pt', filename2='test2.pt'):
+        path1 = os.path.join(test_directory, filename1)
+        path2 = os.path.join(test_directory, filename2)
+        return { 'en': File(path1),
+                 'fr': File(path2) }
+
+
+    def testNoTraversal(self):
+
+        resource = I18nFileResourceFactory(self._createDict(), 'en')\
+                                          (TestRequest())
+
+        self.assertRaises(NotFoundError,
+                          resource.publishTraverse,
+                          resource.request,
+                          '_testData')
+
+    def testFileGET(self):
+
+        # case 1: no language preference, should get en
+        path = os.path.join(test_directory, 'test.txt')
+
+        resource = I18nFileResourceFactory(self._createDict('test.txt'), 'en')\
+                                          (TestRequest())
+
+
+        self.assertEqual(resource.GET(), open(path, 'rb').read())
+
+        response = resource.request.response
+        self.assertEqual(response.getHeader('Content-Type'), 'text/plain')
+
+        # case 2: prefer lt, have only en and fr, should get en
+        resource = I18nFileResourceFactory(
+                        self._createDict('test.txt'), 'en')\
+                        (TestRequest(HTTP_ACCEPT_LANGUAGE='lt'))
+
+        self.assertEqual(resource.GET(), open(path, 'rb').read())
+
+        response = resource.request.response
+        self.assertEqual(response.getHeader('Content-Type'), 'text/plain')
+
+        # case 3: prefer fr, have it, should get fr
+        path = os.path.join(test_directory, 'test2.pt')
+        resource = I18nFileResourceFactory(
+                        self._createDict('test.pt', 'test2.pt'), 'en')\
+                        (TestRequest(HTTP_ACCEPT_LANGUAGE='fr'))
+
+        self.assertEqual(resource.GET(), open(path, 'rb').read())
+
+        response = resource.request.response
+        self.assertEqual(response.getHeader('Content-Type'), 'text/html')
+
+
+    def testFileHEAD(self):
+
+        # case 1: no language preference, should get en
+        resource = I18nFileResourceFactory(self._createDict('test.txt'), 'en')\
+                                          (TestRequest())
+
+        self.assertEqual(resource.HEAD(), '')
+
+        response = resource.request.response
+        self.assertEqual(response.getHeader('Content-Type'), 'text/plain')
+
+        # case 2: prefer lt, have only en and fr, should get en
+        resource = I18nFileResourceFactory(
+                        self._createDict('test.txt'), 'en')\
+                        (TestRequest(HTTP_ACCEPT_LANGUAGE='lt'))
+
+        self.assertEqual(resource.HEAD(), '')
+
+        response = resource.request.response
+        self.assertEqual(response.getHeader('Content-Type'), 'text/plain')
+
+        # case 3: prefer fr, have it, should get fr
+        resource = I18nFileResourceFactory(
+                        self._createDict('test.pt', 'test2.pt'), 'en')\
+                        (TestRequest(HTTP_ACCEPT_LANGUAGE='fr'))
+
+        self.assertEqual(resource.HEAD(), '')
+
+        response = resource.request.response
+        self.assertEqual(response.getHeader('Content-Type'), 'text/html')
+
+
+def test_suite():
+    return makeSuite(Test)
+
+if __name__=='__main__':
+    main(defaultTest='test_suite')