[Zope3-checkins] CVS: Zope3/src/zope/app/traversing/tests - test_etc.py:1.8 test_namespacetrversal.py:1.11 test_presentation.py:1.9 test_skin.py:1.7 test_vh.py:1.4 test_acquire.py:NONE test_atteritem.py:NONE test_directives.py:NONE

Jim Fulton jim at zope.com
Sun Apr 18 12:01:07 EDT 2004


Update of /cvs-repository/Zope3/src/zope/app/traversing/tests
In directory cvs.zope.org:/tmp/cvs-serv12900/src/zope/app/traversing/tests

Modified Files:
	test_etc.py test_namespacetrversal.py test_presentation.py 
	test_skin.py test_vh.py 
Removed Files:
	test_acquire.py test_atteritem.py test_directives.py 
Log Message:
Changed way namespace handlers (handlers for traversing names of the
form "++namespace++name") are registered.  Now the are registered as
views and adapters.  When traversing a namespace-qualified view, a
request is sometimes provided.  When a request is provided, a view
will be used to traverse the name. Otherwise, an adapter is used.
handlers that don't care about the request are registered as both an
adapter and a view.

With this change, it's not possible to have content-specific
namespace-specific traversers.  Content objects can now define
specialized namespaces.


=== Zope3/src/zope/app/traversing/tests/test_etc.py 1.7 => 1.8 ===
--- Zope3/src/zope/app/traversing/tests/test_etc.py:1.7	Sat Apr 17 13:15:35 2004
+++ Zope3/src/zope/app/traversing/tests/test_etc.py	Sun Apr 18 12:00:34 2004
@@ -28,7 +28,7 @@
              import applicationController, applicationControllerRoot
 
         self.assertEqual(
-            etc('process', applicationControllerRoot, None),
+            etc(applicationControllerRoot).traverse('process', ()),
             applicationController)
 
     def testServices(self):
@@ -36,7 +36,7 @@
         class C:
             def getSiteManager(self): return 42
 
-        self.assertEqual(etc('site', C(), None), 42)
+        self.assertEqual(etc(C()).traverse('site', ()), 42)
 
 
 


=== Zope3/src/zope/app/traversing/tests/test_namespacetrversal.py 1.10 => 1.11 ===
--- Zope3/src/zope/app/traversing/tests/test_namespacetrversal.py:1.10	Sat Apr 17 13:15:35 2004
+++ Zope3/src/zope/app/traversing/tests/test_namespacetrversal.py	Sun Apr 18 12:00:34 2004
@@ -16,57 +16,10 @@
 $Id$
 """
 
-from unittest import TestCase, main, makeSuite
-from zope.testing.cleanup import CleanUp # Base class w registry cleanup
-from zope.app.traversing.namespace import provideNamespaceHandler
-from zope.app.traversing.namespace import attr, item
-from zope.app.traversing.adapters import Traverser
-
-class C:
-    a = 1
-    def __getitem__(self, key): return key+'value'
-
-c=C()
-
-def noop(name, ob, request):
-    return ob
-
-
-class Test(CleanUp, TestCase):
-
-    def setUp(self):
-        provideNamespaceHandler('attribute', attr)
-        provideNamespaceHandler('item', item)
-        provideNamespaceHandler('noop', noop)
-
-    def testAttr(self):
-        traverser = Traverser(c)
-        v = traverser.traverse('++attribute++a')
-        self.assertEqual(v, 1)
-
-    def testItem(self):
-        traverser = Traverser(c)
-        v = traverser.traverse('++item++a')
-        self.assertEqual(v, 'avalue')
-
-    def testSideEffectsContextDetail(self):
-        # Check to make sure that when we traverse something in context,
-        # that we get the right context for the result.
-
-        c = C()
-        traverser = Traverser(c)
-        v = traverser.traverse('++noop++yeeha')
-        self.assert_(v is c)
-
-
 def test_suite():
-    suite = makeSuite(Test)
     from doctest import DocTestSuite
-    suite.addTest(DocTestSuite('zope.app.traversing.namespace'))
-    return suite
-
-
-
+    return DocTestSuite('zope.app.traversing.namespace')
 
 if __name__ == '__main__':
+    from unittest import main
     main(defaultTest='test_suite')


=== Zope3/src/zope/app/traversing/tests/test_presentation.py 1.8 => 1.9 ===
--- Zope3/src/zope/app/traversing/tests/test_presentation.py:1.8	Sat Apr 17 13:15:35 2004
+++ Zope3/src/zope/app/traversing/tests/test_presentation.py	Sun Apr 18 12:00:35 2004
@@ -47,14 +47,14 @@
         ztapi.browserView(IContent, 'foo', View)
 
         ob = Content()
-        v = view('foo', ob, TestRequest())
+        v = view(ob, TestRequest()).traverse('foo', ())
         self.assertEqual(v.__class__, View)
 
     def testResource(self):
         ztapi.browserResource('foo', Resource)
 
         ob = Content()
-        r = resource('foo', ob, TestRequest())
+        r = resource(ob, TestRequest()).traverse('foo', ())
         self.assertEqual(r.__class__, Resource)
 
 


=== Zope3/src/zope/app/traversing/tests/test_skin.py 1.6 => 1.7 ===
--- Zope3/src/zope/app/traversing/tests/test_skin.py:1.6	Sat Apr 17 13:15:35 2004
+++ Zope3/src/zope/app/traversing/tests/test_skin.py	Sun Apr 18 12:00:35 2004
@@ -33,7 +33,7 @@
 
         request = FauxRequest()
         ob = object()
-        ob2 = skin('foo', ob, request)
+        ob2 = skin(ob, request).traverse('foo', ())
         self.assertEqual(ob, ob2)
         self.assertEqual(request.skin, 'foo')
         self.assertEqual(request.shifted, 1)


=== Zope3/src/zope/app/traversing/tests/test_vh.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/traversing/tests/test_vh.py:1.3	Sat Apr 17 13:15:35 2004
+++ Zope3/src/zope/app/traversing/tests/test_vh.py	Sun Apr 18 12:00:35 2004
@@ -53,7 +53,7 @@
 
         request = TestRequest(['folder1'], ['folder1_1', '++', 'z', 'y', 'x'])
         ob = object()
-        result = vh('', ob, request)
+        result = vh(ob, request).traverse('', ())
 
         self.assertEqual(result, ob)
         self.assertEqual(request._traversal_stack, ['folder1_1'])
@@ -67,7 +67,8 @@
         # GET /folder1/folder2/++vh++http:host:80/folder1_1
         request = TestRequest(['folder1', 'folder2'], ['folder1_1'])
         ob = object()
-        self.assertRaises(ValueError, vh, 'http:host:80', ob, request)
+        handler = vh(ob, request)
+        self.assertRaises(ValueError, handler.traverse, 'http:host:80', ())
 
 
     def test_vh_host(self):
@@ -75,7 +76,7 @@
 
         request = TestRequest(['folder1'], ['folder1_1', '++'])
         ob = object()
-        result = vh('http:www.fubarco.com:80', ob, request)
+        result = vh(ob, request).traverse('http:www.fubarco.com:80', ())
 
         self.assertEqual(request._app_server, 'http://www.fubarco.com:80')
 

=== Removed File Zope3/src/zope/app/traversing/tests/test_acquire.py ===

=== Removed File Zope3/src/zope/app/traversing/tests/test_atteritem.py ===

=== Removed File Zope3/src/zope/app/traversing/tests/test_directives.py ===




More information about the Zope3-Checkins mailing list