diff --git a/tests/func/test_config.py b/tests/func/test_config.py index e4581dd270..7fa4a45718 100644 --- a/tests/func/test_config.py +++ b/tests/func/test_config.py @@ -1,6 +1,8 @@ +import pytest import configobj from dvc.main import main +from dvc.config import Config, ConfigError from tests.basic_env import TestDvc @@ -83,3 +85,13 @@ def test_non_existing(self): ret = main(["config", "core.non_existing_field", "-u"]) self.assertEqual(ret, 251) + + +def test_set_invalid_key(dvc): + with pytest.raises(ConfigError, match=r"extra keys not allowed"): + dvc.config.set("core", "invalid.key", "value") + + +def test_merging_two_levels(dvc): + dvc.config.set('remote "test"', "url", "https://example.com") + dvc.config.set('remote "test"', "password", "1", level=Config.LEVEL_LOCAL) diff --git a/tests/func/test_remote.py b/tests/func/test_remote.py index 78730d6dad..0e3eb347bd 100644 --- a/tests/func/test_remote.py +++ b/tests/func/test_remote.py @@ -257,18 +257,3 @@ def test_modify_missing_remote(dvc): with pytest.raises(ConfigError, match=r"unable to find remote section"): remote_config.modify("myremote", "gdrive_client_id", "xxx") - - -def test_modify_invalid_key(dvc): - remote_config = RemoteConfig(dvc.config) - remote_config.add("example", "https://example.com") - - with pytest.raises(ConfigError, match=r"extra keys not allowed"): - remote_config.modify("example", "random_key", "value") - - -def test_merging_two_levels(tmp_dir, dvc): - assert 0 == main(["remote", "add", "test", "https://example.com"]) - assert 0 == main(["remote", "modify", "--local", "test", "password", "1"]) - assert "example.com" in (tmp_dir / ".dvc" / "config").read_text() - assert "password" in (tmp_dir / ".dvc" / "config.local").read_text()