diff --git a/scripts/functional_tests.py b/scripts/functional_tests.py index 2fe5427731d..8a8faec10c8 100644 --- a/scripts/functional_tests.py +++ b/scripts/functional_tests.py @@ -63,37 +63,6 @@ job_conf_xml = ''' ''' -def get_static_settings(): - """Returns dictionary of the settings necessary for a galaxy App - to be wrapped in the static middleware. - - This mainly consists of the filesystem locations of url-mapped - static resources. - """ - cwd = os.getcwd() - static_dir = os.path.join( cwd, 'static' ) - # TODO: these should be copied from config/galaxy.ini - return dict( - static_enabled=True, - static_cache_time=360, - static_dir=static_dir, - static_images_dir=os.path.join( static_dir, 'images', '' ), - static_favicon_dir=os.path.join( static_dir, 'favicon.ico' ), - static_scripts_dir=os.path.join( static_dir, 'scripts', '' ), - static_style_dir=os.path.join( static_dir, 'june_2007_style', 'blue' ), - static_robots_txt=os.path.join( static_dir, 'robots.txt' ), - ) - - -def get_webapp_global_conf(): - """Get the global_conf dictionary sent as the first argument to app_factory. - """ - # (was originally sent 'dict()') - nothing here for now except static settings - global_conf = dict() - global_conf.update( get_static_settings() ) - return global_conf - - def generate_config_file( input_filename, output_filename, config_items ): ''' Generate a config file with the configuration that has been defined for the embedded web application. @@ -317,7 +286,7 @@ def main(): # Write a temporary file, based on config/galaxy.ini.sample, using the configuration options defined above. generate_config_file( 'config/galaxy.ini.sample', galaxy_config_file, config_items ) # Set the global_conf[ '__file__' ] option to the location of the temporary .ini file, which gets passed to set_metadata.sh. - kwargs[ 'global_conf' ] = get_webapp_global_conf() + kwargs[ 'global_conf' ] = driver_util.get_webapp_global_conf() kwargs[ 'global_conf' ][ '__file__' ] = galaxy_config_file kwargs[ 'config_file' ] = galaxy_config_file kwargs = load_app_properties( diff --git a/test/base/driver_util.py b/test/base/driver_util.py index bbc0ef09aab..aeda67acb96 100644 --- a/test/base/driver_util.py +++ b/test/base/driver_util.py @@ -16,6 +16,8 @@ import nose.plugins.manager from .nose_util import run from .instrument import StructuredTestDataPlugin +galaxy_root = os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir)) + def setup_tool_shed_tmp_dir(): tool_shed_test_tmp_dir = os.environ.get('TOOL_SHED_TEST_TMP_DIR', None) @@ -83,9 +85,42 @@ def copy_database_template( source, db_path ): raise Exception( "Failed to copy database template from source %s" % source ) +def _get_static_settings(): + """Configuration required for Galaxy static middleware. + + Returns dictionary of the settings necessary for a galaxy App + to be wrapped in the static middleware. + + This mainly consists of the filesystem locations of url-mapped + static resources. + """ + static_dir = os.path.join(galaxy_root, "static") + + # TODO: these should be copied from config/galaxy.ini + return dict( + static_enabled=True, + static_cache_time=360, + static_dir=static_dir, + static_images_dir=os.path.join(static_dir, 'images', ''), + static_favicon_dir=os.path.join(static_dir, 'favicon.ico'), + static_scripts_dir=os.path.join(static_dir, 'scripts', ''), + static_style_dir=os.path.join(static_dir, 'june_2007_style', 'blue'), + static_robots_txt=os.path.join(static_dir, 'robots.txt'), + ) + + +def get_webapp_global_conf(): + """Get the global_conf dictionary sent to ``app_factory``.""" + # (was originally sent 'dict()') - nothing here for now except static settings + global_conf = dict() + global_conf.update( _get_static_settings() ) + return global_conf + + __all__ = [ "configure_environment", "copy_database_template", "build_logger", + "get_webapp_global_conf", "nose_config_and_run", ] diff --git a/test/tool_shed/functional_tests.py b/test/tool_shed/functional_tests.py index f6b4f44148a..01b7a9caa18 100644 --- a/test/tool_shed/functional_tests.py +++ b/test/tool_shed/functional_tests.py @@ -47,35 +47,6 @@ default_galaxy_test_host = 'localhost' default_install_db_merged = False -def get_static_settings(): - """Returns dictionary of the settings necessary for a galaxy App - to be wrapped in the static middleware. - - This mainly consists of the filesystem locations of url-mapped - static resources. - """ - static_dir = os.path.join( galaxy_root, 'static' ) - # TODO: these should be copied from galaxy.ini - return dict( - static_enabled=True, - static_cache_time=360, - static_dir=static_dir, - static_images_dir=os.path.join( static_dir, 'images', '' ), - static_favicon_dir=os.path.join( static_dir, 'favicon.ico' ), - static_scripts_dir=os.path.join( static_dir, 'scripts', '' ), - static_style_dir=os.path.join( static_dir, 'june_2007_style', 'blue' ), - static_robots_txt=os.path.join( static_dir, 'robots.txt' ), - ) - - -def get_webapp_global_conf(): - """Get the global_conf dictionary sent as the first argument to app_factory. - """ - # (was originally sent 'dict()') - nothing here for now except static settings - global_conf = dict() - global_conf.update( get_static_settings() ) - return global_conf - tool_sheds_conf_xml_template = ''' @@ -187,7 +158,7 @@ def main(): else: install_galaxy_db_path = os.path.join( galaxy_db_path, 'install.sqlite' ) install_galaxy_database_connection = 'sqlite:///%s' % install_galaxy_db_path - tool_shed_global_conf = get_webapp_global_conf() + tool_shed_global_conf = driver_util.get_webapp_global_conf() tool_shed_global_conf[ '__file__' ] = 'tool_shed_wsgi.ini.sample' kwargs = dict( admin_users='test@bx.psu.edu', allow_user_creation=True, @@ -303,7 +274,7 @@ def main(): # Generate shed_data_manager_conf.xml if not os.environ.get( 'GALAXY_SHED_DATA_MANAGER_CONF' ): open( galaxy_shed_data_manager_conf_file, 'wb' ).write( shed_data_manager_conf_xml_template ) - galaxy_global_conf = get_webapp_global_conf() + galaxy_global_conf = driver_util.get_webapp_global_conf() galaxy_global_conf[ '__file__' ] = 'config/galaxy.ini.sample' kwargs = dict( allow_user_creation=True,