3 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/e3fe8dd26c25/ Changeset: e3fe8dd26c25 User: jmchilton Date: 2013-12-13 06:24:15 Summary: casperjs: PEP-8 fixes for casperjs_runner.py. Affected #: 1 file diff -r e307768aa1f3a05b4222900df1047bf5d1488003 -r e3fe8dd26c2541d89126a783b954727ef277f620 test/casperjs/casperjs_runner.py --- a/test/casperjs/casperjs_runner.py +++ b/test/casperjs/casperjs_runner.py @@ -18,7 +18,7 @@ import sys ( major, minor, micro, releaselevel, serial ) = sys.version_info if minor < 6: - msg = 'casperjs requires python 2.6 or newer. Using: %s' %( sys.version ) + msg = 'casperjs requires python 2.6 or newer. Using: %s' % ( sys.version ) try: # if nose is installed do a skip test from nose.plugins.skip import SkipTest @@ -36,7 +36,6 @@ import unittest from server_env import TestEnvironment -import pprint import logging logging.basicConfig( stream=sys.stderr, name=__name__ ) log = logging.getLogger( __name__ ) @@ -50,12 +49,14 @@ better way to turn debugging on from the environment """ + # ==================================================================== class HeadlessJSJavascriptError( Exception ): """An error that occurrs in the javascript test file. """ pass + class CasperJSTestCase( unittest.TestCase ): """Casper tests running in a unittest framework. """ @@ -76,7 +77,7 @@ casper_done_str = '# Stopping' # convert js test results to unittest.TestResults - results_adapter = None #CasperJsonToUnittestResultsConverter() + results_adapter = None # CasperJsonToUnittestResultsConverter() # ---------------------------------------------------------------- run the js script def run_js_script( self, rel_script_path, *args, **kwargs ): @@ -166,14 +167,14 @@ """Converts the headless' error from JSON into a more informative python HeadlessJSJavascriptError. """ - get_error = lambda d: d[ 'errors' ][0] - get_msg = lambda err: err[ 'msg' ] - get_trace = lambda err: err[ 'backtrace' ] + get_error = lambda d: d[ 'errors' ][0] + get_msg = lambda err: err[ 'msg' ] + get_trace = lambda err: err[ 'backtrace' ] try: # assume it's json and located in errors (and first) js_test_results = json.loads( stdout_output ) last_error = get_error( js_test_results ) - err_string = ( "%s\n%s" %( get_msg( last_error ), + err_string = ( "%s\n%s" % ( get_msg( last_error ), self.browser_backtrace_to_string( get_trace( last_error ) ) ) ) # if we couldn't parse json from what's returned on the error, dump stdout @@ -187,7 +188,7 @@ except Exception, exc: log.debug( '(failed to parse error returned from %s: %s)', _PATH_TO_HEADLESS, str( exc ) ) return HeadlessJSJavascriptError( - "ERROR in headless browser script %s" %( script_path ) ) + "ERROR in headless browser script %s" % ( script_path ) ) # otherwise, raise with msg and backtrace return HeadlessJSJavascriptError( err_string ) @@ -196,10 +197,10 @@ """Converts list of trace dictionaries (as might be returned from json results) to a string similar to a python backtrace. """ - template = ' File "%s", line %s, in %s' + template = ' File "%s", line %s, in %s' traces = [] for trace in backtrace: - traces.append( template %( trace[ 'file' ], trace[ 'line' ], trace[ 'function' ] ) ) + traces.append( template % ( trace[ 'file' ], trace[ 'line' ], trace[ 'function' ] ) ) return '\n'.join( traces ) # ---------------------------------------------------------------- results @@ -216,7 +217,7 @@ js_test_results = json.loads( results ) failures = js_test_results[ 'testResults' ][ 'failures' ] assert len( failures ) == 0, ( - "%d assertions failed in the headless browser tests" %( len( failures ) ) + "%d assertions failed in the headless browser tests" % ( len( failures ) ) + " (see the log for details)" ) # ---------------------------------------------------------------- TestCase overrides @@ -247,7 +248,7 @@ """ results_dict = json.loads( json_results ) failures = results_dict[ 'testResults' ][ 'failures' ] - passes = results_dict[ 'testResults' ][ 'passes' ] + passes = results_dict[ 'testResults' ][ 'passes' ] self.add_json_failures_to_results( failures, test ) self.add_json_successes_to_results( passes, test ) @@ -271,11 +272,11 @@ """ #TODO: this is all too elaborate fail_type = casper_failure[ 'type' ] - values = json.dumps( casper_failure[ 'values' ] ) - desc = casper_failure[ 'standard' ] + values = json.dumps( casper_failure[ 'values' ] ) + desc = casper_failure[ 'standard' ] if 'messgae' in casper_failure: - desc = capser_failure[ 'message' ] - failure_msg = "(%s) %s: %s" %( fail_type, desc, values ) + desc = casper_failure[ 'message' ] + failure_msg = "(%s) %s: %s" % ( fail_type, desc, values ) #TODO: tb is empty ([]) - can we get file info from casper, covert to py trace? return ( failure_class, failure_msg, [] ) @@ -295,6 +296,7 @@ def setup_module(): log.debug( '\n--------------- setting up module' ) + def teardown_module(): log.debug( '\n--------------- tearing down module' ) @@ -304,6 +306,7 @@ 'password': '123456' } + # ==================================================================== TESTCASE EXAMPLE # these could be broken out into other py files - shouldn't be necc. ATM class Test_01_User( CasperJSTestCase ): https://bitbucket.org/galaxy/galaxy-central/commits/4f2a368ff1ab/ Changeset: 4f2a368ff1ab User: jmchilton Date: 2013-12-13 06:24:15 Summary: casperjs: Fixes for admin checking. Masthead link changed in recent commit. Tweak config file parsing to handle spaces between e-mail addresses. Affected #: 2 files diff -r e3fe8dd26c2541d89126a783b954727ef277f620 -r 4f2a368ff1ab2739c396f4e56e29d8664806dc0b test/casperjs/modules/user.js --- a/test/casperjs/modules/user.js +++ b/test/casperjs/modules/user.js @@ -207,7 +207,7 @@ // check for the setting in sg and the universe_wsgi.ini file var adminData = this.spaceghost.options.adminUser, iniAdminEmails = this.spaceghost.getUniverseSetting( 'admin_users' ); - iniAdminEmails = ( iniAdminEmails )?( iniAdminEmails.split( ',' ) ):( null ); + iniAdminEmails = ( iniAdminEmails )?( iniAdminEmails.split( ',' ).map( function( email ) { return email.trim(); } ) ):( null ); //TODO: seems like we only need the wsgi setting - that's the only thing we can't change if( adminData ){ diff -r e3fe8dd26c2541d89126a783b954727ef277f620 -r 4f2a368ff1ab2739c396f4e56e29d8664806dc0b test/casperjs/spaceghost.js --- a/test/casperjs/spaceghost.js +++ b/test/casperjs/spaceghost.js @@ -1129,7 +1129,7 @@ }, masthead : { - adminLink : '#masthead a[href="/admin"]', + adminLink : '#masthead a[href="/admin/index"]', userMenu : { userEmail : 'a #user-email', userEmail_xpath : '//a[contains(text(),"Logged in as")]/span["id=#user-email"]' https://bitbucket.org/galaxy/galaxy-central/commits/b3eeedb81a1e/ Changeset: b3eeedb81a1e User: jmchilton Date: 2013-12-13 06:24:15 Summary: casperjs: Add some notes. Affected #: 1 file diff -r 4f2a368ff1ab2739c396f4e56e29d8664806dc0b -r b3eeedb81a1e0db8d643af0cbba68f55eb49cdb0 test/casperjs/casperjs_runner.py --- a/test/casperjs/casperjs_runner.py +++ b/test/casperjs/casperjs_runner.py @@ -13,6 +13,16 @@ * casperjs usertests.js --url='http://localhost:8080' --verbose=true --logLevel=debug (see casperjs.org for more information) + +Note: This seems to not work with CasperJS 1.1 (and PhantomJS 1.9) - Casper 1.0.xx and +PhantomJS 1.8 work for me (John). + +Note: Example of specifing user and admin user credentials. + +casperjs api-configuration-tests.js --url="http://localhost:8080" \ + --admin='{"email": "foo@example.com", "password": "123456" }' \ + '{ "testUser": { "email": "foo@example.com", "password": "123456" } }' + """ # -------------------------------------------------------------------- can't do 2.5 import sys Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.