[Zope3-checkins] CVS: Zope3/src/zope/app/publisher/browser/tests - test_directives.py:1.10

Jim Fulton jim@zope.com
Fri, 7 Feb 2003 11:00:17 -0500


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

Modified Files:
	test_directives.py 
Log Message:
Implemented HTTP PUT. Do do this, I had to:

- Implement working HTTP publication, request, response

- Change the server setup so that rather than having a Browser
  server and an XML-RPC server, there is an HTTP server that 
  uses:

  o Browser request, response, and publication for browser (GET, POST, 
    and HEAD) requests,

  o XMLRPC request, response, and publication for xml-rpc (POST 
    w content-type=='text/xml') requests,

  o HTTP request, response, and publication for all other HTTP requests.

  XML-RPC now runs on the same port, 8080, as browser requests.

- Implemented HEAD.

- Implemented some simple PUT views that use the
  file-system-reprentation adapter framework. (This is the replacement
  for VFS that is also used by FTP and may be used as part of
  file-system synchronization.) 
  



=== Zope3/src/zope/app/publisher/browser/tests/test_directives.py 1.9 => 1.10 ===
--- Zope3/src/zope/app/publisher/browser/tests/test_directives.py:1.9	Thu Feb  6 01:49:42 2003
+++ Zope3/src/zope/app/publisher/browser/tests/test_directives.py	Fri Feb  7 10:59:44 2003
@@ -66,6 +66,17 @@
 
 ob = Ob()
 
+class NCV(object):
+    "non callable view"
+    
+    def __init__(self, context, request):
+        pass
+
+class CV(NCV):
+    "callable view"
+    def __call__(self):
+        pass
+
 class Test(PlacelessSetup, unittest.TestCase):
 
     def setUp(self):
@@ -330,6 +341,42 @@
         v = removeAllProxies(v)
         self.assertEqual(v(), 'done')
 
+
+    def testNamedViewNoPagesForCallable(self):
+        self.assertEqual(queryView(ob, 'test', request), None)
+
+        xmlconfig(StringIO(template %
+            """
+            <browser:view
+                  name="test"
+                  class="zope.app.publisher.browser.tests.test_directives.CV"
+                  for="zope.component.tests.views.IC"
+                  permission="zope.Public"
+                  />
+            """
+            ))
+
+        view = getView(ob, 'test', request)
+        view = removeAllProxies(view)
+        self.assertEqual(view.browserDefault(request), (view, ()))
+
+    def testNamedViewNoPagesForNonCallable(self):
+        self.assertEqual(queryView(ob, 'test', request), None)
+
+        xmlconfig(StringIO(template %
+            """
+            <browser:view
+                  name="test"
+                  class="zope.app.publisher.browser.tests.test_directives.NCV"
+                  for="zope.component.tests.views.IC"
+                  permission="zope.Public"
+                  />
+            """
+            ))
+
+        view = getView(ob, 'test', request)
+        view = removeAllProxies(view)
+        self.assertEqual(getattr(view, 'browserDefault', None), None)
 
     def testNamedViewPageViewsNoDefault(self):
         self.assertEqual(queryView(ob, 'test', request), None)