Files
galaxy/test/integration/test_handler_assignment_methods.py
T
John Chilton 45019c3fbd Move galaxy testing utilities into more sane package structure.
Split test/base into lib/galaxy_test/base and lib/galaxy_test/driver. Dividing things on whether they import galaxy-app code or not - with the goal of a galaxy-test-base package that doesn't depend on galaxy-app and a galaxy-test-driver package that does.

I've been refactoring around this division for a long time. Certain tests (namely the integration tests) always need to bootstrap Galaxy - but the API tests and the Selenium tests should be installable and runnable without Galaxy in the Python environment. So future galaxy-test-api and galaxy-test-selenium packages should have only an optional dependency on galaxy-test-driver.

Properly sturcturing these namespaces is a precursor for real packages on PyPI, clean separation of the tool shed testing code, and cleans up all the flake8 noqa hacks in test/.
2019-11-12 09:03:06 -05:00

81 lines
3.1 KiB
Python

"""Integration tests for configurable job handler assignment methods."""
import os
from galaxy_test.driver import integration_util
SCRIPT_DIRECTORY = os.path.abspath(os.path.dirname(__file__))
HANDLER_TEMPLATE_JOB_CONFIG_FILE = os.path.join(SCRIPT_DIRECTORY, "handler_template_job_conf.xml")
class WritesConfig(object):
def _with_handlers_config(self, assign_with=None, default=None, handlers=None):
handlers = handlers or []
template = {
'assign_with': ' assign_with="%s"' % assign_with if assign_with is not None else '',
'default': ' default="%s"' % default if default is not None else '',
'handlers': '\n'.join([
'<handler id="{id}"{tags}/>'.format(
id=x['id'],
tags=' tags="%s"' % x['tags'] if 'tags' in x else ''
) for x in handlers]),
}
self.__write_config_from(HANDLER_TEMPLATE_JOB_CONFIG_FILE, template=template)
def __write_config_from(self, path, template=None):
template = template or {}
self.__write_config(open(path, "r").read().format(**template))
def __write_config(self, contents):
with open(self._app.config.job_config_file, "w") as f:
f.write(contents)
class BaseHandlerAssignmentMethodIntegrationTestCase(integration_util.IntegrationTestCase, WritesConfig):
framework_tool_and_types = True
@classmethod
def handle_galaxy_config_kwds(cls, config):
cls.jobs_directory = cls._test_driver.mkdtemp()
config["jobs_directory"] = cls.jobs_directory
config["job_config_file"] = os.path.join(cls.jobs_directory, "job_conf.xml")
# Disable tool dependency resolution.
config["tool_dependency_dir"] = "none"
class DBPreassignHandlerAssignmentMethodIntegrationTestCase(BaseHandlerAssignmentMethodIntegrationTestCase):
def setUp(self):
self._with_handlers_config(assign_with='db-preassign', handlers=[{'id': 'main'}])
super(DBPreassignHandlerAssignmentMethodIntegrationTestCase, self).setUp()
def test_handler_assignment(self):
tool_id = 'config_vars'
self._run_tool_test(tool_id)
class DBTransactionIsolationHandlerAssignmentMethodIntegrationTestCase(BaseHandlerAssignmentMethodIntegrationTestCase):
def setUp(self):
self._with_handlers_config(assign_with='db-transaction-isolation', handlers=[{'id': 'main'}])
super(DBTransactionIsolationHandlerAssignmentMethodIntegrationTestCase, self).setUp()
def test_handler_assignment(self):
self._skip_unless_postgres()
tool_id = 'config_vars'
self._run_tool_test(tool_id)
class DBSkipLockedHandlerAssignmentMethodIntegrationTestCase(BaseHandlerAssignmentMethodIntegrationTestCase):
def setUp(self):
self._with_handlers_config(assign_with='db-skip-locked', handlers=[{'id': 'main'}])
super(DBSkipLockedHandlerAssignmentMethodIntegrationTestCase, self).setUp()
def test_handler_assignment(self):
self._skip_unless_postgres()
tool_id = 'config_vars'
self._run_tool_test(tool_id)