-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix directory paths configured by the config loader.
Home paths provided in the -h parameter or SLIVKA_HOME were used as is without resolving symlinks. On the other hand, os.getcwd and paths to input and output files were formed with os.realpath which resolved all symlinks. It was actually a problem with an api code converting paths to ids in a hacky way, but changing all paths to real paths works too. Fix #129
- Loading branch information
Showing
3 changed files
with
40 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import os | ||
from unittest import mock | ||
|
||
import pytest | ||
import yaml | ||
|
||
import slivka.conf.loaders | ||
from slivka.compat.resources import open_text | ||
|
||
|
||
@pytest.fixture | ||
def dict_config(): | ||
with open_text('test', 'resources/minimal_project/settings.yaml') as stream: | ||
return yaml.safe_load(stream) | ||
|
||
|
||
def test_conf_directory_real_path(tmp_path, dict_config): | ||
real_home = tmp_path / "real-slivka" | ||
os.mkdir(real_home) | ||
home = tmp_path / "slivka" | ||
os.symlink(real_home, home, target_is_directory=True) | ||
with mock.patch.dict(os.environ, SLIVKA_HOME=str(home)): | ||
conf = slivka.conf.loaders.load_settings_0_3(dict_config) | ||
assert conf.directory.home == str(real_home) | ||
assert conf.directory.jobs == str(real_home / 'jobs') | ||
assert conf.directory.uploads == str(real_home / 'uploads') | ||
assert conf.directory.logs == str(real_home / 'log') | ||
assert conf.directory.services == str(real_home) |