[Zope-CVS] CVS: Packages/FunctionalTests/FunctionalTests - Request.py:1.6 Result.py:1.2 interfaces.py:1.3

Tres Seaver tseaver@zope.com
Fri, 13 Jun 2003 23:23:26 -0400


Update of /cvs-repository/Packages/FunctionalTests/FunctionalTests
In directory cvs.zope.org:/tmp/cvs-serv2504/FunctionalTests

Modified Files:
	Request.py Result.py interfaces.py 
Log Message:


  - Add first pass at payload checking, using PluginFunctions.


=== Packages/FunctionalTests/FunctionalTests/Request.py 1.5 => 1.6 ===
--- Packages/FunctionalTests/FunctionalTests/Request.py:1.5	Sat May 31 15:10:07 2003
+++ Packages/FunctionalTests/FunctionalTests/Request.py	Fri Jun 13 23:22:55 2003
@@ -182,6 +182,7 @@
         self._expected_result = 200
         self._expected_redirect = None
         self._expected_cookies = ()
+        self._payload_checker = None
     
     def _initURLParts( self, URL ):
 
@@ -341,6 +342,13 @@
                     data.append( '%s=%s' % ( name, value ) )
             return '&'.join( data )
 
+    def getPayloadChecker( self ):
+
+        """ See IRequest.
+        """
+        return ( self._payload_checker and self._payload_checker.getFunction()
+                                        or None )
+
     #
     #   Mutators
     #
@@ -400,6 +408,12 @@
 
         self._expected_cookies = cookies
 
+    def setPayloadChecker( self, filename, function ):
+
+        """ See IHTTPRequest.
+        """
+        self._payload_checker = PluginFunction( filename, function )
+
     #
     #   Request invocation
     #
@@ -611,6 +625,11 @@
 
     if 'flush_cookies' in options:
         r.setExpectedCookies( None )
+
+    if 'expected_payload_function' in options:
+        filename = cp.get( section, 'expected_payload_filename' )
+        function = cp.get( section, 'expected_payload_function' )
+        r.setPayloadChecker( filename, function )
     
     r._setOptions( cp, section )
 


=== Packages/FunctionalTests/FunctionalTests/Result.py 1.1 => 1.2 ===
--- Packages/FunctionalTests/FunctionalTests/Result.py:1.1	Tue May 20 21:05:05 2003
+++ Packages/FunctionalTests/FunctionalTests/Result.py	Fri Jun 13 23:22:55 2003
@@ -288,6 +288,15 @@
 
         o Log problems to self._fatal_errors / self._errors
         """
+        checker = request.getPayloadChecker()
+
+        if checker is not None:
+            try:
+                checker( request, invocation.getReplyPayload() )
+            except Exception, error:
+                msg = '[%-10s] : payload error: %s' % ( request.getName()
+                                                    , error )
+                self.logError( msg )
 
     def _validateElapsedTime( self, invocation, request ):
 


=== Packages/FunctionalTests/FunctionalTests/interfaces.py 1.2 => 1.3 ===
--- Packages/FunctionalTests/FunctionalTests/interfaces.py:1.2	Sat May 31 15:10:07 2003
+++ Packages/FunctionalTests/FunctionalTests/interfaces.py	Fri Jun 13 23:22:55 2003
@@ -215,6 +215,13 @@
             in getContentType().
         """
 
+    def getPayloadChecker():
+
+        """ Return a function used to validate the response payload.
+
+        o Return None if no function is assigned.
+        """
+
     def addHeader( header_desc ):
 
         """ Construct a header tuple and add it to our list.
@@ -253,6 +260,11 @@
     def setExpectedCookies( cookies ):
 
         """ Override the default expected response time, in seconds.
+        """
+
+    def setPayloadChecker( filename, function ):
+
+        """ Create a checker function as a plugin function.
         """