Skip to content

Commit

Permalink
tests: move tests from remote to config
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr. Outis committed Jan 19, 2020
1 parent efcddb6 commit 566cc6c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
12 changes: 12 additions & 0 deletions tests/func/test_config.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down Expand Up @@ -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)
15 changes: 0 additions & 15 deletions tests/func/test_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 566cc6c

Please sign in to comment.