Skip to content

Commit

Permalink
Merge pull request iterative#3132 from mroutis/fix-3131
Browse files Browse the repository at this point in the history
remote: error out when modifying a non-existing remote
  • Loading branch information
efiop authored Jan 14, 2020
2 parents 563f75e + ff094b2 commit 69e91f2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
5 changes: 3 additions & 2 deletions dvc/remote/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
import posixpath
from urllib.parse import urlparse

from dvc.config import Config
from dvc.config import ConfigError
from dvc.config import Config, ConfigError
from dvc.utils import relpath


Expand Down Expand Up @@ -134,6 +133,8 @@ def remove(self, name, level=None):
break

def modify(self, name, option, value, level=None):
self.get_settings(name)

self.config.set(
Config.SECTION_REMOTE_FMT.format(name), option, value, level=level
)
Expand Down
11 changes: 9 additions & 2 deletions tests/func/test_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import pytest
from mock import patch

from dvc.config import Config
from dvc.config import Config, ConfigError
from dvc.exceptions import DownloadError, UploadError
from dvc.main import main
from dvc.path_info import PathInfo
Expand All @@ -31,10 +31,10 @@ def test(self):

self.assertEqual(main(["remote", "list"]), 0)

self.assertEqual(main(["remote", "remove", remotes[0]]), 0)
self.assertEqual(
main(["remote", "modify", remotes[0], "option", "value"]), 0
)
self.assertEqual(main(["remote", "remove", remotes[0]]), 0)

self.assertEqual(main(["remote", "list"]), 0)

Expand Down Expand Up @@ -250,3 +250,10 @@ def test_raise_on_too_many_open_files(tmp_dir, dvc, tmp_path_factory, mocker):
with pytest.raises(OSError) as e:
dvc.push()
assert e.errno == errno.EMFILE


def test_modify_missing_remote(dvc):
remote_config = RemoteConfig(dvc.config)

with pytest.raises(ConfigError, match=r"unable to find remote section"):
remote_config.modify("myremote", "gdrive_client_id", "xxx")

0 comments on commit 69e91f2

Please sign in to comment.