Commits

James Taylor committed b01fb80

Update to functional test patch

  • Participants
  • Parent commits ec44df4

Comments (0)

Files changed (1)

functional-test-harness

+# HG changeset patch
+# User James Taylor <james@jamestaylor.org>
+# Date 1256058509 14400
+# Node ID 9a3344273059c3d4b5d7daa7811cba29e4d13d16
+# Parent  ea29f33390d3ba471c31d1aa69736a52c311128a
+New functional test harness. Update to recent nose. No longer rely on nose to manage the embedded web server (this is not done in functional_tests.py). Log page contents to a temporary file on check_page_for_string error.
+
+[mq]: functional-test-harness
+
 diff --git a/eggs.ini b/eggs.ini
 --- a/eggs.ini
 +++ b/eggs.ini
  elif [ $1 = 'help' ]; then
  	echo "'run_functional_tests.sh'                       for testing all the tools in functional directory"
  	echo "'run_functional_tests.sh aaa'                   for testing one test case of 'aaa' ('aaa' is the file name with path)"
-@@ -22,7 +22,7 @@
+@@ -13,16 +13,16 @@
+ 	echo "'run_functional_tests.sh -sid ccc'              for testing one section with sid 'ccc' ('ccc' is the string after 'section::')"
+ 	echo "'run_functional_tests.sh -list'                 for listing all the tool ids"
+ elif [ $1 = '-id' ]; then
+-	python -ES ./scripts/nosetests.py -v -w test functional.test_toolbox:TestForTool_$2 --with-nosehtml --html-report-file run_functional_tests.html
++	python -ES ./scripts/functional_tests.py -v functional.test_toolbox:TestForTool_$2 --with-nosehtml --html-report-file run_functional_tests.html
+ elif [ $1 = '-sid' ]; then
+-        python -ES ./scripts/nosetests.py --with-nosehtml --html-report-file run_functional_tests.html -v -w test `python tool_list.py $2`
++        python -ES ./scripts/functional_tests.py --with-nosehtml --html-report-file run_functional_tests.html -v `python tool_list.py $2`
+ elif [ $1 = '-list' ]; then
+         python tool_list.py
+ 	echo "==========================================================================================================================================="
  	echo "'run_functional_tests.sh -id bbb'               for testing one tool with id 'bbb' ('bbb' is the tool id)"
  	echo "'run_functional_tests.sh -sid ccc'              for testing one section with sid 'ccc' ('ccc' is the string after 'section::')"
  else
 new file mode 100644
 --- /dev/null
 +++ b/scripts/functional_tests.py
-@@ -0,0 +1,206 @@
+@@ -0,0 +1,211 @@
 +#!/usr/bin/env python
 +
 +import os, sys
 +    if 'HTTP_ACCEPT_LANGUAGE' not in os.environ:
 +        os.environ['HTTP_ACCEPT_LANGUAGE'] = default_galaxy_locales
 +    galaxy_test_file_dir = os.environ.get( 'GALAXY_TEST_FILE_DIR', default_galaxy_test_file_dir )
++    if not os.path.isabs( galaxy_test_file_dir ):
++        galaxy_test_file_dir = os.path.join( os.getcwd(), galaxy_test_file_dir )
 +    start_server = 'GALAXY_TEST_EXTERNAL' not in os.environ   
 +    if start_server:
 +        if 'GALAXY_TEST_DBPATH' in os.environ:
 +            default_cluster_job_runner = os.environ['GALAXY_TEST_DEF_RUNNER']
 +        else:
 +            default_cluster_job_runner = 'local:///'
++            
++    print "Database connection:", database_connection
 +    
 +    # What requires these?        
 +    os.environ['GALAXY_TEST_HOST'] = galaxy_test_host
 +                                   tool_config_file = "tool_conf.xml.sample",
 +                                   datatype_converters_config_file = "datatype_converters_conf.xml.sample",
 +                                   tool_path = "tools",
++                                   tool_parse_help = False,
 +                                   test_conf = "test.conf",
 +                                   log_destination = "stdout",
 +                                   use_heartbeat = False,
 diff --git a/test/base/twilltestcase.py b/test/base/twilltestcase.py
 --- a/test/base/twilltestcase.py
 +++ b/test/base/twilltestcase.py
-@@ -761,7 +761,7 @@
+@@ -1,7 +1,7 @@
+ import pkg_resources
+ pkg_resources.require( "twill==0.9" )
+ 
+-import StringIO, os, sys, random, filecmp, time, unittest, urllib, logging, difflib, zipfile
++import StringIO, os, sys, random, filecmp, time, unittest, urllib, logging, difflib, zipfile, tempfile
+ from itertools import *
+ 
+ import twill
+@@ -650,15 +650,25 @@
+         self.visit_page( "user/logout" )
+         self.check_page_for_string( "You are no longer logged in" )
+         self.home()
++    
+     # Functions associated with browsers, cookies, HTML forms and page visits
++    
+     def check_page_for_string( self, patt ):
+         """Looks for 'patt' in the current browser page"""
+         page = self.last_page()
+         for subpatt in patt.split():
+             if page.find( patt ) == -1:
+-                errmsg = "TwillAssertionError: no match to '%s'" %patt
++                fname = self.write_temp_file( page )
++                errmsg = "no match to '%s'\npage content written to '%s'" % ( patt, fname )
+                 raise AssertionError( errmsg )
+ 
++    def write_temp_file( self, content ):
++        fd, fname = tempfile.mkstemp( suffix='.html', prefix='twilltestcase-' )
++        f = os.fdopen( fd, "w" )
++        f.write( content )
++        f.close()
++        return fname
++
+     def clear_cookies( self ):
+         tc.clear_cookies()
+ 
+@@ -825,7 +835,7 @@
      def wait( self, maxiter=20 ):
          """Waits for the tools to finish"""
          count = 0
          self.home()
          while count < maxiter:
              count += 1
-@@ -769,7 +769,7 @@
+@@ -833,7 +843,7 @@
              page = tc.browser.get_html()
              if page.find( '<!-- running: do not change this comment, used by TwillTestCase.wait -->' ) > -1:
                  time.sleep( sleep_amount )