From a747294bd9dc2bf60de2b2be2bd463f72e2a9880 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Thu, 2 Jul 2020 11:52:14 -0400 Subject: [PATCH] Refactor toward test case independence from Galaxy. --- lib/galaxy_test/base/env.py | 24 ++++++++++++++++++++++++ lib/galaxy_test/driver/driver_util.py | 22 +--------------------- lib/galaxy_test/driver/testcase.py | 3 ++- test/functional/test_toolbox.py | 2 +- 4 files changed, 28 insertions(+), 23 deletions(-) create mode 100644 lib/galaxy_test/base/env.py diff --git a/lib/galaxy_test/base/env.py b/lib/galaxy_test/base/env.py new file mode 100644 index 00000000000..ab8436d51f1 --- /dev/null +++ b/lib/galaxy_test/base/env.py @@ -0,0 +1,24 @@ +"""Base utilities for working Galaxy test environments. +""" +import os +import socket + +DEFAULT_WEB_HOST = socket.gethostbyname('localhost') + + +def setup_keep_outdir(): + keep_outdir = os.environ.get('GALAXY_TEST_SAVE', '') + if keep_outdir > '': + try: + os.makedirs(keep_outdir) + except Exception: + pass + return keep_outdir + + +def target_url_parts(): + host = socket.gethostbyname(os.environ.get('GALAXY_TEST_HOST', DEFAULT_WEB_HOST)) + port = os.environ.get('GALAXY_TEST_PORT') + default_url = "http://%s:%s" % (host, port) + url = os.environ.get('GALAXY_TEST_EXTERNAL', default_url) + return host, port, url diff --git a/lib/galaxy_test/driver/driver_util.py b/lib/galaxy_test/driver/driver_util.py index 1936bb47cc9..01507e81ede 100644 --- a/lib/galaxy_test/driver/driver_util.py +++ b/lib/galaxy_test/driver/driver_util.py @@ -41,13 +41,13 @@ from galaxy.util import asbool, download_to_file, galaxy_directory from galaxy.util.properties import load_app_properties from galaxy.web import buildapp from galaxy_test.base.api_util import get_master_api_key, get_user_api_key +from galaxy_test.base.env import DEFAULT_WEB_HOST, target_url_parts from galaxy_test.base.instrument import StructuredTestDataPlugin from galaxy_test.base.nose_util import run from tool_shed.webapp.app import UniverseApplication as ToolshedUniverseApplication from .test_logging import logging_config_file galaxy_root = galaxy_directory() -DEFAULT_WEB_HOST = socket.gethostbyname('localhost') DEFAULT_CONFIG_PREFIX = "GALAXY" GALAXY_TEST_DIRECTORY = os.path.join(galaxy_root, "test") GALAXY_TEST_FILE_DIR = "test-data,https://github.com/galaxyproject/galaxy-test-data.git" @@ -1078,24 +1078,6 @@ def drive_test(test_driver_class): sys.exit(test_driver.run()) -def setup_keep_outdir(): - keep_outdir = os.environ.get('GALAXY_TEST_SAVE', '') - if keep_outdir > '': - try: - os.makedirs(keep_outdir) - except Exception: - pass - return keep_outdir - - -def target_url_parts(): - host = socket.gethostbyname(os.environ.get('GALAXY_TEST_HOST', DEFAULT_WEB_HOST)) - port = os.environ.get('GALAXY_TEST_PORT') - default_url = "http://%s:%s" % (host, port) - url = os.environ.get('GALAXY_TEST_EXTERNAL', default_url) - return host, port, url - - __all__ = ( "copy_database_template", "build_logger", @@ -1106,9 +1088,7 @@ __all__ = ( "database_conf", "get_webapp_global_conf", "nose_config_and_run", - "setup_keep_outdir", "setup_galaxy_config", - "target_url_parts", "TestDriver", "wait_for_http_server", ) diff --git a/lib/galaxy_test/driver/testcase.py b/lib/galaxy_test/driver/testcase.py index 3e063148fc0..a05dc5bb287 100644 --- a/lib/galaxy_test/driver/testcase.py +++ b/lib/galaxy_test/driver/testcase.py @@ -6,7 +6,8 @@ import unittest from galaxy.security import idencoding from galaxy.tool_util.verify.test_data import TestDataResolver -from .driver_util import GalaxyTestDriver, setup_keep_outdir, target_url_parts +from galaxy_test.base.env import setup_keep_outdir, target_url_parts +from .driver_util import GalaxyTestDriver log = logging.getLogger(__name__) diff --git a/test/functional/test_toolbox.py b/test/functional/test_toolbox.py index 24e45a5c8e7..c55dfce9af6 100644 --- a/test/functional/test_toolbox.py +++ b/test/functional/test_toolbox.py @@ -10,8 +10,8 @@ except ImportError: from galaxy.tool_util.verify.interactor import GalaxyInteractorApi, verify_tool from galaxy.tools import DataManagerTool +from galaxy_test.base.env import setup_keep_outdir, target_url_parts from galaxy_test.base.instrument import register_job_data -from galaxy_test.driver.driver_util import setup_keep_outdir, target_url_parts from galaxy_test.driver.testcase import FunctionalTestCase log = logging.getLogger(__name__)