[Zope3-checkins] CVS: Zope3/src/zope/app/browser/tests - test_absoluteurl.py:1.16.6.1 test_menu.py:1.9.30.1

Jim Fulton cvs-admin at zope.org
Sun Nov 9 11:08:45 EST 2003


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

Modified Files:
      Tag: adaptergeddon-branch
	test_absoluteurl.py test_menu.py 
Log Message:
Created a global presentation service that replaces the 
global view, resource, and skin services.

Now look up presentation components by adapting from a request type,
rather than adapting to a presentation type.





=== Zope3/src/zope/app/browser/tests/test_absoluteurl.py 1.16 => 1.16.6.1 ===
--- Zope3/src/zope/app/browser/tests/test_absoluteurl.py:1.16	Sun Sep 21 13:31:10 2003
+++ Zope3/src/zope/app/browser/tests/test_absoluteurl.py	Sun Nov  9 11:08:13 2003
@@ -18,18 +18,19 @@
 """
 
 from unittest import TestCase, main, makeSuite
+
+from zope.app.tests import ztapi
 from zope.interface import Interface, implements
 
 from zope.app.tests.placelesssetup import PlacelessSetup
 from zope.component import getService, getView
-from zope.app.services.servicenames import Adapters, Views
+from zope.app.services.servicenames import Adapters
 
 from zope.i18n.interfaces import IUserPreferredCharsets
 
-from zope.publisher.tests.httprequest import TestRequest
+from zope.publisher.browser import TestRequest
 from zope.publisher.http import IHTTPRequest
 from zope.publisher.http import HTTPCharsets
-from zope.publisher.interfaces.browser import IBrowserPresentation
 from zope.app.container.contained import contained
 
 
@@ -47,47 +48,40 @@
         PlacelessSetup.setUp(self)
         from zope.app.browser.absoluteurl \
              import AbsoluteURL, SiteAbsoluteURL
-        provideView=getService(None,Views).provideView
-        provideView(None, 'absolute_url', IBrowserPresentation,
-                    [AbsoluteURL])
-        provideView(IRoot, 'absolute_url', IBrowserPresentation,
-                    [SiteAbsoluteURL])
+        ztapi.browserView(None, 'absolute_url', [AbsoluteURL])
+        ztapi.browserView(IRoot, 'absolute_url', [SiteAbsoluteURL])
         provideAdapter = getService(None, Adapters).provideAdapter
         provideAdapter(IHTTPRequest, IUserPreferredCharsets, HTTPCharsets)
 
     def testBadObject(self):
         request = TestRequest()
-        request.setViewType(IBrowserPresentation)
         view = getView(42, 'absolute_url', request)
         self.assertRaises(TypeError, view.__str__)
 
     def testNoContext(self):
         request = TestRequest()
-        request.setViewType(IBrowserPresentation)
         view = getView(Root(), 'absolute_url', request)
-        self.assertEqual(str(view), 'http://foobar.com')
+        self.assertEqual(str(view), 'http://127.0.0.1')
 
     def testBasicContext(self):
         request = TestRequest()
-        request.setViewType(IBrowserPresentation)
 
         content = contained(TrivialContent(), Root(), name='a')
         content = contained(TrivialContent(), content, name='b')
         content = contained(TrivialContent(), content, name='c')
         view = getView(content, 'absolute_url', request)
-        self.assertEqual(str(view), 'http://foobar.com/a/b/c')
+        self.assertEqual(str(view), 'http://127.0.0.1/a/b/c')
 
         breadcrumbs = view.breadcrumbs()
         self.assertEqual(breadcrumbs,
-                         ({'name':  '', 'url': 'http://foobar.com'},
-                          {'name': 'a', 'url': 'http://foobar.com/a'},
-                          {'name': 'b', 'url': 'http://foobar.com/a/b'},
-                          {'name': 'c', 'url': 'http://foobar.com/a/b/c'},
+                         ({'name':  '', 'url': 'http://127.0.0.1'},
+                          {'name': 'a', 'url': 'http://127.0.0.1/a'},
+                          {'name': 'b', 'url': 'http://127.0.0.1/a/b'},
+                          {'name': 'c', 'url': 'http://127.0.0.1/a/b/c'},
                           ))
 
     def testVirtualHosting(self):
         request = TestRequest()
-        request.setViewType(IBrowserPresentation)
 
         vh_root = TrivialContent()
         content = contained(vh_root, Root(), name='a')
@@ -95,18 +89,17 @@
         content = contained(TrivialContent(), content, name='b')
         content = contained(TrivialContent(), content, name='c')
         view = getView(content, 'absolute_url', request)
-        self.assertEqual(str(view), 'http://foobar.com/b/c')
+        self.assertEqual(str(view), 'http://127.0.0.1/b/c')
 
         breadcrumbs = view.breadcrumbs()
         self.assertEqual(breadcrumbs,
-         ({'name':  '', 'url': 'http://foobar.com'},
-          {'name': 'b', 'url': 'http://foobar.com/b'},
-          {'name': 'c', 'url': 'http://foobar.com/b/c'},
+         ({'name':  '', 'url': 'http://127.0.0.1'},
+          {'name': 'b', 'url': 'http://127.0.0.1/b'},
+          {'name': 'c', 'url': 'http://127.0.0.1/b/c'},
           ))
 
     def testVirtualHostingWithVHElements(self):
         request = TestRequest()
-        request.setViewType(IBrowserPresentation)
 
         vh_root = TrivialContent()
         content = contained(vh_root, Root(), name='a')
@@ -114,18 +107,17 @@
         content = contained(TrivialContent(), content, name='b')
         content = contained(TrivialContent(), content, name='c')
         view = getView(content, 'absolute_url', request)
-        self.assertEqual(str(view), 'http://foobar.com/b/c')
+        self.assertEqual(str(view), 'http://127.0.0.1/b/c')
 
         breadcrumbs = view.breadcrumbs()
         self.assertEqual(breadcrumbs,
-         ({'name':  '', 'url': 'http://foobar.com'},
-          {'name': 'b', 'url': 'http://foobar.com/b'},
-          {'name': 'c', 'url': 'http://foobar.com/b/c'},
+         ({'name':  '', 'url': 'http://127.0.0.1'},
+          {'name': 'b', 'url': 'http://127.0.0.1/b'},
+          {'name': 'c', 'url': 'http://127.0.0.1/b/c'},
           ))
 
     def testVirtualHostingInFront(self):
         request = TestRequest()
-        request.setViewType(IBrowserPresentation)
 
         root = Root()
         request._vh_root = contained(root, root, name='')
@@ -134,14 +126,14 @@
         content = contained(TrivialContent(), content, name='b')
         content = contained(TrivialContent(), content, name='c')
         view = getView(content, 'absolute_url', request)
-        self.assertEqual(str(view), 'http://foobar.com/a/b/c')
+        self.assertEqual(str(view), 'http://127.0.0.1/a/b/c')
 
         breadcrumbs = view.breadcrumbs()
         self.assertEqual(breadcrumbs,
-         ({'name':  '', 'url': 'http://foobar.com'},
-          {'name': 'a', 'url': 'http://foobar.com/a'},
-          {'name': 'b', 'url': 'http://foobar.com/a/b'},
-          {'name': 'c', 'url': 'http://foobar.com/a/b/c'},
+         ({'name':  '', 'url': 'http://127.0.0.1'},
+          {'name': 'a', 'url': 'http://127.0.0.1/a'},
+          {'name': 'b', 'url': 'http://127.0.0.1/a/b'},
+          {'name': 'c', 'url': 'http://127.0.0.1/a/b/c'},
           ))
 
 


=== Zope3/src/zope/app/browser/tests/test_menu.py 1.9 => 1.9.30.1 ===
--- Zope3/src/zope/app/browser/tests/test_menu.py:1.9	Fri Jun  6 17:35:20 2003
+++ Zope3/src/zope/app/browser/tests/test_menu.py	Sun Nov  9 11:08:13 2003
@@ -17,17 +17,16 @@
 """
 
 import unittest
+
+from zope.app.tests import ztapi
 from zope.interface import Interface, implements
 
 from zope.component import getService, getServiceManager
-from zope.app.services.servicenames import Views
-from zope.app.services.tests.placefulsetup \
-           import PlacefulSetup
+from zope.app.services.tests.placefulsetup import PlacefulSetup
 
 from zope.app.browser.menu import MenuAccessView
-
+from zope.publisher.browser import TestRequest
 from zope.publisher.interfaces.browser import IBrowserView
-from zope.publisher.interfaces.browser import IBrowserPresentation
 from zope.app.publication.traversers import TestTraverser
 from zope.security.management import newSecurityManager
 from zope.security.checker import defineChecker, NamesChecker, CheckerPublic
@@ -81,29 +80,21 @@
 
         defineService('BrowserMenu', IBrowserMenuService)
         provideService('BrowserMenu', Service())
-        getService(None,Views).provideView(
-            I, 'a3', IBrowserPresentation, [V])
-        getService(None, Views).provideView(None, '_traverse',
-                            IBrowserPresentation, [TestTraverser])
+        ztapi.browserView(I, 'a3', [V])
+        ztapi.browserView(None, '_traverse', [TestTraverser])
         defineChecker(C, NamesChecker(['a1', 'a2', 'a3', '__call__'],
                                       CheckerPublic,
                                       abad='waaa'))
 
     def test(self):
         newSecurityManager('who')
-        v = MenuAccessView(ProxyFactory(ob), Request())
+        v = MenuAccessView(ProxyFactory(ob), TestRequest())
         self.assertEqual(v['zmi_views'],
                          [{'description': '', 'title':'l1', 'action':'a1'},
                           {'description': '', 'title':'l2', 'action':'a2/a3'},
                           {'description': '', 'title':'l3', 'action':'@@a3'}
                           ])
 
-
-class Request:
-    def getPresentationType(self):
-        return IBrowserPresentation
-    def getPresentationSkin(self):
-        return ''
 
 def test_suite():
     loader = unittest.TestLoader()




More information about the Zope3-Checkins mailing list