mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-26 07:18:31 +01:00
Merge pull request #3193 from mroutis/fix-3192
config: verify before saving a modification
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -33,11 +35,11 @@ class TestConfigCLI(TestDvc):
|
||||
self.assertEqual(ret, 0)
|
||||
|
||||
def _do_test(self, local=False):
|
||||
section = "setsection"
|
||||
field = "setfield"
|
||||
section = "core"
|
||||
field = "analytics"
|
||||
section_field = "{}.{}".format(section, field)
|
||||
value = "setvalue"
|
||||
newvalue = "setnewvalue"
|
||||
value = "True"
|
||||
newvalue = "False"
|
||||
|
||||
base = ["config"]
|
||||
if local:
|
||||
@@ -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)
|
||||
|
||||
@@ -32,7 +32,7 @@ class TestRemote(TestDvc):
|
||||
self.assertEqual(main(["remote", "list"]), 0)
|
||||
|
||||
self.assertEqual(
|
||||
main(["remote", "modify", remotes[0], "option", "value"]), 0
|
||||
main(["remote", "modify", remotes[0], "checksum_jobs", "1"]), 0
|
||||
)
|
||||
self.assertEqual(main(["remote", "remove", remotes[0]]), 0)
|
||||
|
||||
@@ -113,7 +113,7 @@ class TestRemoteRemoveDefault(TestDvc):
|
||||
|
||||
class TestRemoteRemove(TestDvc):
|
||||
def test(self):
|
||||
ret = main(["config", "core.jobs", "1"])
|
||||
ret = main(["config", "core.checksum_jobs", "1"])
|
||||
self.assertEqual(ret, 0)
|
||||
|
||||
remote = "mys3"
|
||||
|
||||
Reference in New Issue
Block a user