[Zope-CVS] CVS: Packages/FunctionalTests/FunctionalTests - ScenarioGenerator.py:1.4
Tres Seaver
tseaver@zope.com
Fri, 23 May 2003 18:02:23 -0400
Update of /cvs-repository/Packages/FunctionalTests/FunctionalTests
In directory cvs.zope.org:/tmp/cvs-serv17675/FunctionalTests
Modified Files:
ScenarioGenerator.py
Log Message:
- Change 'portal_url' to 'site_host'.
- Strip leading 'site_path' from URL, if present.
- Render "foreign" URLs without the parameterization.
=== Packages/FunctionalTests/FunctionalTests/ScenarioGenerator.py 1.3 => 1.4 ===
--- Packages/FunctionalTests/FunctionalTests/ScenarioGenerator.py:1.3 Fri May 23 17:21:44 2003
+++ Packages/FunctionalTests/FunctionalTests/ScenarioGenerator.py Fri May 23 18:02:23 2003
@@ -23,7 +23,14 @@
[Request_%(REQUEST_NUM)03d]
HTTP_Verb: %(HTTP_VERB)s
HTTP_Version: %(HTTP_VERSION)s
-URL: %%(portal_url)s/%%(site_path)s%(REQUEST_URI)s
+URL: %%(site_host)s/%%(site_path)s%(REQUEST_URI)s
+"""
+
+_FOREIGN_REQUEST_SKELETON = """
+[Request_%(REQUEST_NUM)03d]
+HTTP_Verb: %(HTTP_VERB)s
+HTTP_Version: %(HTTP_VERSION)s
+URL: %(REQUEST_URI)s
"""
_AUTHENTICATION_SKELETON = """\
@@ -46,7 +53,7 @@
[DEFAULT]
userid: userid
password: password
-portal_url: %(portal_url)s
+site_host: %(site_host)s
site_path: %(site_path)s
"""
@@ -65,6 +72,8 @@
_exclude_patterns = []
_exclude_file = None
_exclude_regex = None
+ _site_host = None
+ _site_path = None
def __init__( self, args ):
@@ -77,7 +86,8 @@
sys.stderr.write( """
%(GENERATOR_EXE)s [-?vq] \\
[-l log_dir] [-f log_prefix] [-e log_extension] \\
- [-o file] [-x pattern] [-X file]
+ [-o file] [-x pattern] [-X file] \\
+ [-u site_host] [-r site_path]
-?, --help Print this help message
@@ -108,6 +118,12 @@
-X, --exclude-file Exclude requests which match any pattern
read from 'file' (one pattern per line).
+ -u, --site-host Specify the host / port of the site being
+ tested.
+
+ -r, --site-path Specify the path to the "base" of the
+ site being tested.
+
%(MESSAGE)s\n""" % { 'GENERATOR_EXE' : sys.argv[0]
, 'LOGFILE_DIRECTORY' : self._logfile_directory
, 'LOGFILE_PREFIX' : self._logfile_prefix
@@ -123,11 +139,11 @@
verbosity = self._verbosity
capture_cookies = self._capture_cookies
logfile_directory = logfile_prefix = logfile_extension = None
- output_file = exclude_file = portal_url = site_path = None
+ output_file = exclude_file = site_host = site_path = None
try:
opts, ignored = getopt.getopt( args
- , "?vqcCl:f:e:o:x:X:"
+ , "?vqcCl:f:e:o:x:X:u:r:"
, [ 'help'
, 'verbose'
, 'quiet'
@@ -139,6 +155,8 @@
, 'output-file'
, 'exclude-pattern'
, 'exclude-file'
+ , 'site-host='
+ , 'site-path='
]
)
except getopt.GetoptError, msg:
@@ -179,6 +197,12 @@
if o == '-X' or o == '--exclude-file':
exclude_file = v
+ if o == '-u' or o == '--site-host':
+ site_host = v
+
+ if o == '-r' or o == '--site-path':
+ site_path = v
+
self._verbosity = verbosity
self._capture_cookies = capture_cookies
@@ -191,6 +215,12 @@
if logfile_extension is not None:
self._logfile_extension = logfile_extension
+ if site_host is not None:
+ self._site_host = site_host
+
+ if site_path is not None:
+ self._site_path = site_path
+
if output_file is not None:
if output_file == '-':
self._output_file = sys.stdout
@@ -344,25 +374,36 @@
( scheme
, netloc
, path
- , params
+ , url_parm
, query
, fragment
) = urlparse.urlparse( uri )
- if scheme and parms.get( 'portal_url' ) is None:
- parms[ 'portal_url' ] = urlparse.urlunparse(
- ( scheme, netloc, '', '', '', '' ) )
+ site_host = urlparse.urlunparse( ( scheme, netloc, '', '', '', '' ) )
+
+ if scheme and parms.get( 'site_host' ) is None:
+ parms[ 'site_host' ] = site_host
+
+ if site_host == parms[ 'site_host' ]:
+
+ template = _REQUEST_SKELETON
+
+ if self._site_path and path.startswith( self._site_path ):
+ path = path[ len( self._site_path ) : ]
+
+ uri = urlparse.urlunparse(
+ ( '', '', path, url_parm, query, fragment ) )
+ else: # foreign site!
- site_relative_uri = urlparse.urlunparse(
- ( '', '', path, params, query, fragment ) )
+ template = _FOREIGN_REQUEST_SKELETON
request_num = request_num + 1
- self._print( _REQUEST_SKELETON
+ self._print( template
, REQUEST_NUM=request_num
, HTTP_VERB=http_verb
, HTTP_VERSION=http_version
- , REQUEST_URI=site_relative_uri
+ , REQUEST_URI=uri
)
headers = rfc822.Message( f )
@@ -408,8 +449,8 @@
request_num = 0
parms = { 'saw_authentication' : 0
- , 'portal_url' : None
- , 'site_path' : None
+ , 'site_host' : self._site_host
+ , 'site_path' : self._site_path
}
filenames = glob.glob( glob_pattern )