Files

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

77 lines
2.9 KiB
Python
Raw Permalink Normal View History

"""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")
2020-10-06 18:49:19 +01:00
class WritesConfig:
def _with_handlers_config(self, assign_with=None, default=None, handlers=None):
handlers = handlers or []
template = {
2022-09-22 12:34:45 +01:00
"assign_with": f' assign_with="{assign_with}"' if assign_with is not None else "",
"default": f' default="{default}"' if default is not None else "",
2020-01-23 09:55:11 +00:00
"handlers": "\n".join(
2022-09-22 12:34:45 +01:00
'<handler id="{id}"{tags}/>'.format(
id=x["id"], tags=' tags="{}"'.format(x["tags"]) if "tags" in x else ""
)
2020-01-23 09:55:11 +00:00
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 {}
2020-10-06 18:49:19 +01:00
self.__write_config(open(path).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):
2022-04-20 10:50:37 +02:00
super().handle_galaxy_config_kwds(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 TestDBPreassignHandlerAssignmentMethodIntegration(BaseHandlerAssignmentMethodIntegrationTestCase):
def setUp(self):
self._with_handlers_config(assign_with="db-preassign", handlers=[{"id": "main"}])
2020-10-06 18:49:19 +01:00
super().setUp()
def test_handler_assignment(self):
tool_id = "config_vars"
self._run_tool_test(tool_id)
class TestDBTransactionIsolationHandlerAssignmentMethodIntegration(BaseHandlerAssignmentMethodIntegrationTestCase):
def setUp(self):
self._with_handlers_config(assign_with="db-transaction-isolation", handlers=[{"id": "main"}])
2020-10-06 18:49:19 +01:00
super().setUp()
def test_handler_assignment(self):
self._skip_unless_postgres()
tool_id = "config_vars"
self._run_tool_test(tool_id)
class TestDBSkipLockedHandlerAssignmentMethodIntegration(BaseHandlerAssignmentMethodIntegrationTestCase):
def setUp(self):
self._with_handlers_config(assign_with="db-skip-locked", handlers=[{"id": "main"}])
2020-10-06 18:49:19 +01:00
super().setUp()
def test_handler_assignment(self):
self._skip_unless_postgres()
tool_id = "config_vars"
self._run_tool_test(tool_id)