mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Allows describing hierarchical data in JSON or inferring structure from archives or directories. Datasets or archive sources can be specified via uploads, URLs, paths (if admin && allow_path_paste), library_import_dir/user_library_import_dir, and/or FTP imports. Unlike existing API endpoints, a mix of these on a per file basis is allowed and they work seemlessly between libraries and histories. Supported "archives" include gzip, zip, bagit directories, bagit achives (with fetching and validations of downloads). The existing upload API endpoint is quite rough to work with both in terms of adding parameters (e.g. the file type and dbkey hanlding in 4563 was difficult to implement, terribly hacky, and should seemingly have been trivial) and in terms of building requests (one needs to build a tool form - not describe sensible inputs in JSON). This API is built to be intelligable from an API standpoint instead of being constrained to the older style tool form. Additionally it built with hierarchical data in mind in a way that would not be easy at all enhancing the tool form components we don't even render. This implements 5159 though much simpler YAML descriptions of data libraries should be possible basically as the API descriptions. We can replace the data library script in Ephemeris https://github.com/galaxyproject/ephemeris/blob/master/ephemeris/setup_data_libraries.py with one that converts a simple YAML file into an API call and allows many new options for free. In future PRs I'll add filtering options to this and it will serve as the backend to 4733.
106 lines
3.1 KiB
Python
106 lines
3.1 KiB
Python
"""Utilities for constructing Galaxy integration tests.
|
|
|
|
Tests that start an actual Galaxy server with a particular configuration in
|
|
order to test something that cannot be tested with the default functional/api
|
|
tessting configuration.
|
|
"""
|
|
import os
|
|
from unittest import skip, TestCase
|
|
|
|
from galaxy.tools.deps.commands import which
|
|
from galaxy.tools.verify.test_data import TestDataResolver
|
|
from .api import UsesApiTestCaseMixin
|
|
from .driver_util import GalaxyTestDriver
|
|
|
|
NO_APP_MESSAGE = "test_case._app called though no Galaxy has been configured."
|
|
|
|
|
|
def skip_if_jenkins(cls):
|
|
|
|
if os.environ.get("BUILD_NUMBER", ""):
|
|
return skip
|
|
|
|
return cls
|
|
|
|
|
|
def skip_unless_executable(executable):
|
|
if which(executable):
|
|
return lambda func: func
|
|
return skip("PATH doesn't contain executable %s" % executable)
|
|
|
|
|
|
def skip_unless_docker():
|
|
return skip_unless_executable("docker")
|
|
|
|
|
|
class IntegrationTestCase(TestCase, UsesApiTestCaseMixin):
|
|
"""Unit test case with utilities for spinning up Galaxy."""
|
|
|
|
prefer_template_database = True
|
|
# Subclasses can override this to force uwsgi for tests.
|
|
require_uwsgi = False
|
|
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
"""Configure and start Galaxy for a test."""
|
|
cls._app_available = False
|
|
cls._test_driver = GalaxyTestDriver()
|
|
cls._prepare_galaxy()
|
|
cls._test_driver.setup(config_object=cls)
|
|
cls._app_available = True
|
|
cls._configure_app()
|
|
|
|
@classmethod
|
|
def tearDownClass(cls):
|
|
"""Shutdown Galaxy server and cleanup temp directory."""
|
|
cls._test_driver.tear_down()
|
|
cls._app_available = False
|
|
|
|
def setUp(self):
|
|
self.test_data_resolver = TestDataResolver()
|
|
# Setup attributes needed for API testing...
|
|
server_wrapper = self._test_driver.server_wrappers[0]
|
|
host = server_wrapper.host
|
|
port = server_wrapper.port
|
|
self.url = "http://%s:%s" % (host, port)
|
|
self._setup_interactor()
|
|
|
|
@property
|
|
def _app(self):
|
|
assert self._app_available, NO_APP_MESSAGE
|
|
return self._test_driver.app
|
|
|
|
@property
|
|
def _tempdir(self):
|
|
return self._test_driver.galaxy_test_tmp_dir
|
|
|
|
@classmethod
|
|
def _prepare_galaxy(cls):
|
|
"""Extension point for subclasses called before Galaxy is launched."""
|
|
|
|
@classmethod
|
|
def _configure_app(cls):
|
|
"""Extension point for subclasses called after Galaxy is launched.
|
|
|
|
```self._app``` can be used to access Galaxy core app.
|
|
"""
|
|
|
|
@classmethod
|
|
def handle_galaxy_config_kwds(cls, galaxy_config_kwds):
|
|
"""Extension point for subclasses to modify arguments used to configure Galaxy.
|
|
|
|
This method will be passed the keyword argument pairs used to call
|
|
Galaxy Config object and can modify the Galaxy instance created for
|
|
the test as needed.
|
|
"""
|
|
|
|
@classmethod
|
|
def handle_uwsgi_cli_command(cls, command):
|
|
"""Extension point sub subclasses to modify arguments used to launch uWSGI server.
|
|
|
|
Command will a list that can be modified.
|
|
"""
|
|
|
|
def _run_tool_test(self, *args, **kwargs):
|
|
return self._test_driver.run_tool_test(*args, **kwargs)
|