tests: move tests from remote to config

This commit is contained in:
Mr. Outis
2020-01-19 02:29:07 -06:00
parent efcddb6f5b
commit 566cc6c862
2 changed files with 12 additions and 15 deletions
+12
View File
@@ -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 @@ class TestConfigCLI(TestDvc):
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)
-15
View File
@@ -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()