Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Galaxy options required for persistent serve environment.
Namely --file_path, --database_connection, --shed_tool_conf, --shed_tool_path. Each default-able in ~/.planemo.yml. Add some initial and basic tests for ``planemo.galaxy.config`` and rework pre-seeding database ahead of implementing profiles for the above options.
- Loading branch information
Showing
5 changed files
with
156 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
"""Unit tests for ``planemo.galaxy.config``.""" | ||
import contextlib | ||
import os | ||
|
||
from .test_utils import TempDirectoryContext, test_context | ||
|
||
from planemo.galaxy.config import galaxy_config | ||
|
||
|
||
def test_defaults(): | ||
"""Test by default Galaxy files are stored in temp ``config_directory``.""" | ||
with _test_galaxy_config() as config: | ||
config_directory = config.config_directory | ||
_assert_property_is(config, "file_path", os.path.join(config_directory, "files")) | ||
conn = "sqlite:///%s/galaxy.sqlite?isolation_level=IMMEDIATE" % config_directory | ||
_assert_property_is(config, "database_connection", conn) | ||
|
||
|
||
def test_database_connection_override_path(): | ||
"""Test by default Galaxy files are stored in temp ``config_directory``.""" | ||
conn = "postgresql://username:password@localhost/mydatabase" | ||
with _test_galaxy_config(database_connection=conn) as config: | ||
_assert_property_is(config, "database_connection", conn) | ||
|
||
|
||
def test_override_files_path(): | ||
"""Test Galaxy file path overrideable with --file_path.""" | ||
with TempDirectoryContext() as tdc: | ||
with _test_galaxy_config(file_path=tdc.temp_directory) as config: | ||
_assert_property_is(config, "file_path", tdc.temp_directory) | ||
|
||
|
||
def _assert_property_is(config, prop, value): | ||
env_var = "GALAXY_CONFIG_OVERRIDE_%s" % prop.upper() | ||
assert config.env[env_var] == value | ||
|
||
|
||
@contextlib.contextmanager | ||
def _test_galaxy_config(tool_paths=[], **kwargs): | ||
ctx = test_context() | ||
with TempDirectoryContext() as tdc: | ||
test_data = os.path.join(tdc.temp_directory, "test-data") | ||
os.makedirs(test_data) | ||
kwargs["test_data"] = test_data | ||
with galaxy_config(ctx, tool_paths, **kwargs) as gc: | ||
yield gc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters