[Zope3-checkins] CVS: Zope3/src/zope/app/publisher/browser/tests - test_directoryresource.py:1.2 test_icondirective.py:1.13 test_resource.py:1.7

Sidnei da Silva sidnei at x3ng.com.br
Wed Sep 24 13:22:08 EDT 2003


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

Modified Files:
	test_directoryresource.py test_icondirective.py 
	test_resource.py 
Log Message:
Fix directoryResource the same way as other resources, plus make a test for the generated URL and fix Resource.__call__ accordingly.

=== Zope3/src/zope/app/publisher/browser/tests/test_directoryresource.py 1.1 => 1.2 ===
--- Zope3/src/zope/app/publisher/browser/tests/test_directoryresource.py:1.1	Mon Aug 11 10:58:13 2003
+++ Zope3/src/zope/app/publisher/browser/tests/test_directoryresource.py	Wed Sep 24 13:22:07 2003
@@ -18,11 +18,13 @@
 import os
 from unittest import TestCase, main, makeSuite
 
-from zope.proxy import isProxy, removeAllProxies
-from zope.security.checker import NamesChecker
 from zope.exceptions import NotFoundError
+from zope.proxy import isProxy, removeAllProxies
 from zope.publisher.browser import TestRequest
+from zope.security.checker import NamesChecker, ProxyFactory
+from zope.interface import implements
 
+from zope.app import zapi
 from zope.app.tests.placelesssetup import PlacelessSetup
 from zope.app.publisher.browser.directoryresource import \
      DirectoryResourceFactory
@@ -30,6 +32,8 @@
 from zope.app.publisher.browser.pagetemplateresource import \
      PageTemplateResource
 import zope.app.publisher.browser.tests as p
+from zope.app.interfaces.traversing import IContainmentRoot
+from zope.app.interfaces.services.service import ISite
 
 test_directory = os.path.split(p.__file__)[0]
 
@@ -37,6 +41,12 @@
     ('get', '__getitem__', 'request', 'publishTraverse')
     )
 
+class Site:
+    implements(ISite, IContainmentRoot)
+
+site = Site()
+
+
 class Test(PlacelessSetup, TestCase):
 
     def setUp(self):
@@ -61,8 +71,18 @@
         path = os.path.join(test_directory, 'testfiles')
         request = TestRequest()
         resource = DirectoryResourceFactory(path, checker)(request)
-        file = resource['test.txt']
+        file = ProxyFactory(resource['test.txt'])
         self.assert_(isProxy(file))
+
+    def testURL(self):
+        request = TestRequest()
+        request._vh_root = site
+        path = os.path.join(test_directory, 'testfiles')
+        files = DirectoryResourceFactory(path, checker)(request)
+        files.__parent__ = site
+        files.__name__ = 'test_files'
+        file = files['test.gif']
+        self.assertEquals(file(), 'http://127.0.0.1/@@/test_files/test.gif')
 
     def testCorrectFactories(self):
         path = os.path.join(test_directory, 'testfiles')


=== Zope3/src/zope/app/publisher/browser/tests/test_icondirective.py 1.12 => 1.13 ===
--- Zope3/src/zope/app/publisher/browser/tests/test_icondirective.py:1.12	Mon Sep 22 18:37:26 2003
+++ Zope3/src/zope/app/publisher/browser/tests/test_icondirective.py	Wed Sep 24 13:22:07 2003
@@ -91,7 +91,6 @@
             % rname)
 
         resource = ProxyFactory(getResource(ob, rname, request))
-
         self.assertRaises(Forbidden, getattr, resource, '_testData')
         resource = removeAllProxies(resource)
         self.assertEqual(resource._testData(), open(path, 'rb').read())
@@ -122,9 +121,6 @@
             % rname)
 
         resource = ProxyFactory(getResource(ob, rname, request))
-
-        # Resources come ready-wrapped from the factory
-        #resource = ProxyFactory(resource)
 
         self.assertRaises(Forbidden, getattr, resource, '_testData')
         resource = removeAllProxies(resource)


=== Zope3/src/zope/app/publisher/browser/tests/test_resource.py 1.6 => 1.7 ===
--- Zope3/src/zope/app/publisher/browser/tests/test_resource.py:1.6	Sun Sep 21 13:32:42 2003
+++ Zope3/src/zope/app/publisher/browser/tests/test_resource.py	Wed Sep 24 13:22:07 2003
@@ -19,7 +19,7 @@
 from zope.app.publisher.browser.resource import Resource
 from zope.interface import implements
 from zope.publisher.browser import TestRequest
-from zope.app.interfaces.services.service import ISite 
+from zope.app.interfaces.services.service import ISite
 from zope.app.tests.placelesssetup import PlacelessSetup
 from zope.app.interfaces.traversing import IContainmentRoot
 
@@ -27,7 +27,7 @@
     implements(ISite, IContainmentRoot)
 
 site = Site()
-        
+
 class TestResource(PlacelessSetup, unittest.TestCase):
 
     def testGlobal(self):




More information about the Zope3-Checkins mailing list