mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-25 00:12:08 +08:00
Factor out overriding tempdir into own method
This commit is contained in:
@@ -348,11 +348,16 @@ class GalaxyAppConfiguration(BaseAppConfiguration, CommonConfigurationMixin):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super(GalaxyAppConfiguration, self).__init__(**kwargs)
|
||||
self._override_tempdir(kwargs)
|
||||
self._process_config(kwargs)
|
||||
|
||||
def _load_schema(self):
|
||||
return AppSchema(GALAXY_CONFIG_SCHEMA_PATH, GALAXY_APP_NAME)
|
||||
|
||||
def _override_tempdir(self, kwargs):
|
||||
if string_as_bool(kwargs.get("override_tempdir", "True")):
|
||||
tempfile.tempdir = self.new_file_path
|
||||
|
||||
def _process_config(self, kwargs):
|
||||
# Resolve paths of other config files
|
||||
self.parse_config_file_options(kwargs)
|
||||
@@ -377,10 +382,6 @@ class GalaxyAppConfiguration(BaseAppConfiguration, CommonConfigurationMixin):
|
||||
self.thread_local_log = threading.local()
|
||||
# Install database related configuration (if different)
|
||||
self.install_database_engine_options = get_database_engine_options(kwargs, model_prefix="install_")
|
||||
|
||||
override_tempdir = string_as_bool(kwargs.get("override_tempdir", "True"))
|
||||
if override_tempdir:
|
||||
tempfile.tempdir = self.new_file_path
|
||||
self.shared_home_dir = kwargs.get("shared_home_dir")
|
||||
self.cookie_path = kwargs.get("cookie_path")
|
||||
self.tool_path = self._in_root_dir(self.tool_path)
|
||||
|
||||
@@ -169,7 +169,8 @@ def mock_config_running_not_from_source(monkeypatch, mock_config_file):
|
||||
|
||||
@pytest.fixture
|
||||
def appconfig(monkeypatch):
|
||||
return config.Configuration()
|
||||
monkeypatch.setattr(config.GalaxyAppConfiguration, '_override_tempdir', lambda a, b: None)
|
||||
return config.GalaxyAppConfiguration()
|
||||
|
||||
|
||||
def test_root(appconfig):
|
||||
@@ -196,7 +197,8 @@ def test_common_base_config(appconfig):
|
||||
|
||||
|
||||
def get_config_data():
|
||||
configuration = config.Configuration()
|
||||
config.GalaxyAppConfiguration._override_tempdir = lambda a, b: None # method must be mocked
|
||||
configuration = config.GalaxyAppConfiguration()
|
||||
ev = ExpectedValues(configuration)
|
||||
items = ((k, v) for k, v in configuration.schema.app_schema.items() if k not in DO_NOT_TEST)
|
||||
for key, data in items:
|
||||
|
||||
@@ -22,6 +22,7 @@ def get_schema(app_mapping):
|
||||
def mock_init(monkeypatch):
|
||||
monkeypatch.setattr(AppSchema, '_read_schema', lambda a, b: get_schema(MOCK_SCHEMA))
|
||||
monkeypatch.setattr(GalaxyAppConfiguration, '_process_config', lambda a, b: None)
|
||||
monkeypatch.setattr(GalaxyAppConfiguration, '_override_tempdir', lambda a, b: None)
|
||||
|
||||
|
||||
def test_load_config_from_schema(mock_init):
|
||||
|
||||
@@ -49,6 +49,7 @@ def test_basecase(monkeypatch):
|
||||
}
|
||||
monkeypatch.setattr(AppSchema, '_read_schema', lambda a, b: get_schema(mock_schema))
|
||||
monkeypatch.setattr(GalaxyAppConfiguration, '_process_config', lambda a, b: None)
|
||||
monkeypatch.setattr(GalaxyAppConfiguration, '_override_tempdir', lambda a, b: None)
|
||||
|
||||
config = GalaxyAppConfiguration()
|
||||
assert config.component1_path0 == 'value0'
|
||||
@@ -159,6 +160,7 @@ def test_resolves_with_empty_component(monkeypatch):
|
||||
}
|
||||
monkeypatch.setattr(AppSchema, '_read_schema', lambda a, b: get_schema(mock_schema))
|
||||
monkeypatch.setattr(GalaxyAppConfiguration, '_process_config', lambda a, b: None)
|
||||
monkeypatch.setattr(GalaxyAppConfiguration, '_override_tempdir', lambda a, b: None)
|
||||
|
||||
config = GalaxyAppConfiguration()
|
||||
assert config.path0 == 'value0'
|
||||
|
||||
@@ -44,6 +44,7 @@ def test_deprecated_prefixes_set_correctly(monkeypatch):
|
||||
# Before we mock them, check that correct values are assigned
|
||||
monkeypatch.setattr(AppSchema, '_read_schema', lambda a, b: get_schema(MOCK_SCHEMA))
|
||||
monkeypatch.setattr(GalaxyAppConfiguration, '_process_config', lambda a, b: None)
|
||||
monkeypatch.setattr(GalaxyAppConfiguration, '_override_tempdir', lambda a, b: None)
|
||||
|
||||
config = GalaxyAppConfiguration()
|
||||
assert config.deprecated_dirs == {'config_dir': 'config', 'data_dir': 'database'}
|
||||
@@ -53,6 +54,7 @@ def test_deprecated_prefixes_set_correctly(monkeypatch):
|
||||
def mock_init(monkeypatch):
|
||||
monkeypatch.setattr(AppSchema, '_read_schema', lambda a, b: get_schema(MOCK_SCHEMA))
|
||||
monkeypatch.setattr(GalaxyAppConfiguration, '_process_config', lambda a, b: None)
|
||||
monkeypatch.setattr(GalaxyAppConfiguration, '_override_tempdir', lambda a, b: None)
|
||||
monkeypatch.setattr(GalaxyAppConfiguration, 'deprecated_dirs', MOCK_DEPRECATED_DIRS)
|
||||
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ def mock_init(monkeypatch):
|
||||
|
||||
monkeypatch.setattr(AppSchema, '_read_schema', lambda a, b: get_schema(MOCK_SCHEMA))
|
||||
monkeypatch.setattr(GalaxyAppConfiguration, '_process_config', lambda a, b: None)
|
||||
monkeypatch.setattr(GalaxyAppConfiguration, '_override_tempdir', lambda a, b: None)
|
||||
|
||||
|
||||
def test_update_property(mock_init, monkeypatch):
|
||||
|
||||
Reference in New Issue
Block a user