[Zope-CVS] CVS: Packages/FunctionalTests/FunctionalTests - FTRunner.py:1.2 Framework.py:1.2
Tres Seaver
tseaver@zope.com
Tue, 20 May 2003 09:21:56 -0400
Update of /cvs-repository/Packages/FunctionalTests/FunctionalTests
In directory cvs.zope.org:/tmp/cvs-serv28561/FunctionalTests
Modified Files:
FTRunner.py Framework.py
Log Message:
- Fold in SRLs work for checking redirects.
- Stub in checking content (need to figure out how we want to proceed
here: the XPath-based stuff SRL did may be fine).
=== Packages/FunctionalTests/FunctionalTests/FTRunner.py 1.1 => 1.2 ===
--- Packages/FunctionalTests/FunctionalTests/FTRunner.py:1.1 Thu Apr 24 17:39:51 2003
+++ Packages/FunctionalTests/FunctionalTests/FTRunner.py Tue May 20 09:21:25 2003
@@ -11,6 +11,8 @@
_verbosity = 1
_time_requests = 1
_check_responses = 1
+ _check_redirects = 1
+ _check_content = 1
_check_elapsed_times = 1
_time_requests = 1
_config_file = '.zftrc'
@@ -39,9 +41,17 @@
-T, --no-time-requests Don't time requests
- -r, --check-responses Check expected HTTP respose codes (default)
+ -r, --check-responses Check expected HTTP response codes (default)
- -R, --no-check-responses Don't check expected HTTP respose codes
+ -R, --no-check-responses Don't check expected HTTP response codes
+
+ -d, --check-redirects Check expected HTTP redirects (default)
+
+ -D, --no-check-redirects Don't check expected HTTP redirects
+
+ -c, --check-content Check expected payload (default)
+
+ -C, --no-check-content Don't check payload
-e, --check-elapsed_times Check elapsed times (default)
@@ -82,16 +92,21 @@
verbosity = 1
portal_url = site_path = config_file = None
time_requests = check_responses = check_elapsed_times = None
+ check_redirects = check_content = None
try:
opts, arglist = getopt.getopt( args
- , "?tTrReEvqc:u:p:"
+ , "?tTrRcCdDeEvqc:u:p:"
, [ 'help'
, 'time-requests'
, 'no-time-requests'
, 'check-responses'
, 'no-check-responses'
, 'check-elapsed_times'
+ , 'check-redirects'
+ , 'no-check-redirects'
+ , 'check-content'
+ , 'no-check-content'
, 'no-check-elapsed_times'
, 'verbose'
, 'quiet'
@@ -120,6 +135,18 @@
if o == '-R' or o == '--no-check-responses':
check_responses = 0
+ if o == '-d' or o == '--check-redirects':
+ check_redirects = 1
+
+ if o == '-D' or o == '--no-check-redirects':
+ check_redirects = 0
+
+ if o == '-c' or o == '--check-content':
+ check_content = 1
+
+ if o == '-C' or o == '--no-check-content':
+ check_content = 0
+
if o == '-e' or o == '--check-elapsed_times':
check_elapsed_times = 1
@@ -179,6 +206,12 @@
if check_responses is not None:
self._check_responses = check_responses
+ if check_redirects is not None:
+ self._check_redirects = check_redirects
+
+ if check_content is not None:
+ self._check_content = check_content
+
if check_elapsed_times is not None:
self._check_elapsed_times = check_elapsed_times
@@ -232,6 +265,16 @@
, self._check_responses
)
+ self._check_redirects = cp.get( 'Options'
+ , 'Check_Redirects'
+ , self._check_redirects
+ )
+
+ self._check_content = cp.get( 'Options'
+ , 'Check_Content'
+ , self._check_content
+ )
+
self._check_elapsed_times = cp.get( 'Options'
, 'Check_Elapsed_Times'
, self._check_elapsed_times
@@ -323,6 +366,8 @@
, app=self.getZopeApp()
, time_requests=self._time_requests
, check_responses=self._check_responses
+ , check_redirects=self._check_redirects
+ , check_content=self._check_content
, check_elapsed_times=self._check_elapsed_times
)
=== Packages/FunctionalTests/FunctionalTests/Framework.py 1.1 => 1.2 ===
--- Packages/FunctionalTests/FunctionalTests/Framework.py:1.1 Thu Apr 24 17:39:51 2003
+++ Packages/FunctionalTests/FunctionalTests/Framework.py Tue May 20 09:21:25 2003
@@ -27,6 +27,8 @@
, defaults={}
, time_requests=1
, check_responses=1
+ , check_redirects=1
+ , check_content=1
, check_elapsed_times=1
):
@@ -37,6 +39,8 @@
self._state = {}
self._time_requests = time_requests
self._check_responses = check_responses
+ self._check_redirects = check_redirects
+ self._check_content = check_content
self._check_elapsed_times = check_elapsed_times and time_requests
self._invocations = []
self._errors = []
@@ -123,6 +127,18 @@
Should we validate response values?
"""
return self._check_responses
+
+ def checkRedirects( self ):
+ """
+ Should we validate redirect locations?
+ """
+ return self._check_redirects
+
+ def checkContent( self ):
+ """
+ Should we validate content?
+ """
+ return self._check_content
def checkElapsedTimes( self ):
"""
@@ -221,6 +237,8 @@
, invocation
, request
, force_check_response=0
+ , force_check_redirects=0
+ , force_check_content=0
, force_check_time=0
):
@@ -232,11 +250,25 @@
if got != expected:
msg = '[%-10s] response: %s != %s' % ( rname , got, expected )
self._fatal_errors.append( msg )
+
+ # make sure we're being redirected to the right place.
+ if self.checkRedirects() or force_check_redirects:
+ expected = request.getExpectedRedirect()
+ if expected != None:
+ expected = expected.strip()
+ got = invocation.getRedirect()
+ if got != expected:
+ msg = '[%-10s] response: %s != %s' % ( rname
+ , got, expected )
+ self._fatal_errors.append( msg )
- elif self.checkElapsedTimes() or force_check_time:
+ if self.checkContent() or force_check_content:
+ pass # TODO: Add SRL's XPath checking?
+
+ if self.checkElapsedTimes() or force_check_time:
expected = request.getExpectedTime()
- got = invocation.getElapsedTime()
- if got != expected:
+ got = invocation.getInterval()
+ if got > expected:
msg = '[%-10s] elapsed: %s != %s' % ( rname, got, expected )
self._errors.append( msg )
@@ -295,6 +327,16 @@
def getReplyStatus( self ):
return '%d %s' % ( self._reply_code, self._reply_message )
+ def getReplyPayload( self ):
+ return self._reply_payload
+
+ def getRedirect( self ):
+ """
+ Return a string describing where we're being redirected
+ to, if anywhere.
+ """
+ return self._reply_headers.get( 'Location' )
+
def getCookies( self ):
"""
Return a sequence (maybe empty) of Cookie objects describing
@@ -1013,6 +1055,8 @@
, defaults={}
, time_requests=1
, check_responses=1
+ , check_redirects=1
+ , check_content=1
, check_elapsed_times=1
):
"""
@@ -1025,6 +1069,8 @@
, defaults
, time_requests
, check_responses
+ , check_redirects
+ , check_content
, check_elapsed_times
)
try: