Files
dvc/tests/unit/test_config.py
T
Ruslan Kuprieiev 7afff1ef29 config: use wtree for non-repo configs (#4341)
For example, when `dvc import`ing something, dvc won't see stuff
declared in system and global configs, because GitTree doesn't see stuff
that is outside of the git repo.

Discord context:
https://discordapp.com/channels/485586884165107732/563406153334128681/740543492417126521
2020-08-06 17:37:21 +03:00

36 lines
930 B
Python

import os
import pytest
from dvc.config import Config
from dvc.tree.local import LocalTree
@pytest.mark.parametrize(
"path, expected",
[
("cache", "../cache"),
(os.path.join("..", "cache"), "../../cache"),
(os.getcwd(), os.getcwd().replace("\\", "/")),
("ssh://some/path", "ssh://some/path"),
],
)
def test_to_relpath(path, expected):
assert Config._to_relpath(os.path.join(".", "config"), path) == expected
def test_get_tree(tmp_dir, scm):
tmp_dir.scm_gen("foo", "foo", commit="add foo")
tree = scm.get_tree("master")
config = Config(tree=tree)
assert config.tree == tree
assert config.wtree != tree
assert isinstance(config.wtree, LocalTree)
assert config._get_tree("repo") == tree
assert config._get_tree("local") == config.wtree
assert config._get_tree("global") == config.wtree
assert config._get_tree("system") == config.wtree