From e309c7f6ebaf7b29a00902af9fb71fd69fac4070 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Mon, 28 Mar 2016 11:06:13 -0400 Subject: [PATCH] Make XXX_TEST_DBPATH and XXX_TEST_DB_TEMPLATE generic and shared with shed. Now the variable TOOL_SHED_TEST_DB_TEMPLATE works as one might expect like GALAXY_TEST_DB_TEMPLATE. --- scripts/functional_tests.py | 2 +- test/base/driver_util.py | 17 ++++++++++------- test/tool_shed/functional_tests.py | 8 +++----- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/scripts/functional_tests.py b/scripts/functional_tests.py index ad6f8441881..7ec71a99d5e 100644 --- a/scripts/functional_tests.py +++ b/scripts/functional_tests.py @@ -154,7 +154,7 @@ def main(): template_cache_path = os.path.join( galaxy_db_path, 'compiled_templates' ) new_file_path = tempfile.mkdtemp( prefix='new_files_path_', dir=tempdir ) job_working_directory = tempfile.mkdtemp( prefix='job_working_directory_', dir=tempdir ) - database_connection, database_auto_migrate = driver_util.galaxy_database_conf(galaxy_db_path) + database_connection, database_auto_migrate = driver_util.database_conf(galaxy_db_path) install_database_conf = driver_util.install_database_conf(galaxy_db_path, default_merged=True) kwargs = {} for dir in file_path, new_file_path, template_cache_path: diff --git a/test/base/driver_util.py b/test/base/driver_util.py index fe3ccc3defd..1b61b21be66 100644 --- a/test/base/driver_util.py +++ b/test/base/driver_util.py @@ -149,20 +149,23 @@ def copy_database_template( source, db_path ): raise Exception( "Failed to copy database template from source %s" % source ) -def galaxy_database_conf(db_path): +def database_conf(db_path, prefix="GALAXY"): """Find (and populate if needed) Galaxy database connection.""" database_auto_migrate = False - if 'GALAXY_TEST_DBURI' in os.environ: - database_connection = os.environ['GALAXY_TEST_DBURI'] + dburi_var = "%s_TEST_DBURI" % prefix + if dburi_var in os.environ: + database_connection = os.environ[dburi_var] else: - db_path = os.path.join(db_path, 'universe.sqlite') - if 'GALAXY_TEST_DB_TEMPLATE' in os.environ: + default_db_filename = "%s.sqlite" % prefix.lower() + template_var = "%s_TEST_DB_TEMPLATE" % prefix + db_path = os.path.join(db_path, default_db_filename) + if template_var in os.environ: # Middle ground between recreating a completely new # database and pointing at existing database with # GALAXY_TEST_DBURI. The former requires a lot of setup # time, the latter results in test failures in certain # cases (namely tool shed tests expecting clean database). - copy_database_template(os.environ['GALAXY_TEST_DB_TEMPLATE'], db_path) + copy_database_template(os.environ[template_var], db_path) database_auto_migrate = True database_connection = 'sqlite:///%s' % db_path return database_connection, database_auto_migrate @@ -297,7 +300,7 @@ __all__ = [ "FRAMEWORK_UPLOAD_TOOL_CONF", "FRAMEWORK_SAMPLE_TOOLS_CONF", "FRAMEWORK_DATATYPES_CONF", - "galaxy_database_conf", + "database_conf", "get_webapp_global_conf", "nose_config_and_run", "setup_galaxy_config", diff --git a/test/tool_shed/functional_tests.py b/test/tool_shed/functional_tests.py index 60008df8f45..b0b8c34d896 100644 --- a/test/tool_shed/functional_tests.py +++ b/test/tool_shed/functional_tests.py @@ -92,11 +92,8 @@ def main(): hgweb_config_dir = hgweb_config_file_path os.environ[ 'TEST_HG_WEB_CONFIG_DIR' ] = hgweb_config_dir print "Directory location for hgweb.config:", hgweb_config_dir - if 'TOOL_SHED_TEST_DBURI' in os.environ: - toolshed_database_connection = os.environ[ 'TOOL_SHED_TEST_DBURI' ] - else: - toolshed_database_connection = 'sqlite:///' + os.path.join( shed_db_path, 'community_test.sqlite' ) - galaxy_database_connection, galaxy_database_auto_migrate = driver_util.galaxy_database_conf(galaxy_db_path) + toolshed_database_connection, toolshed_database_auto_migrate = driver_util.database_conf(shed_db_path, prefix="TOOL_SHED") + galaxy_database_connection, galaxy_database_auto_migrate = driver_util.database_conf(galaxy_db_path) install_database_conf = driver_util.install_database_conf(galaxy_db_path, default_merged=False) tool_shed_global_conf = driver_util.get_webapp_global_conf() tool_shed_global_conf[ '__file__' ] = 'tool_shed_wsgi.ini.sample' @@ -104,6 +101,7 @@ def main(): allow_user_creation=True, allow_user_deletion=True, database_connection=toolshed_database_connection, + database_auto_migrate=toolshed_database_auto_migrate, datatype_converters_config_file='datatype_converters_conf.xml.sample', file_path=shed_file_path, global_conf=tool_shed_global_conf,