mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-12 07:18:23 +01:00
tests: move tests from remote to config
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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user