Skip to content

Commit

Permalink
remote: modify: fix --unset (#3939)
Browse files Browse the repository at this point in the history
  • Loading branch information
efiop authored Jun 2, 2020
1 parent fd65f44 commit 72dcbc0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
6 changes: 5 additions & 1 deletion dvc/command/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ class CmdRemoteModify(CmdRemote):
def run(self):
with self.config.edit(self.args.level) as conf:
self._check_exists(conf)
conf["remote"][self.args.name][self.args.option] = self.args.value
section = conf["remote"][self.args.name]
if self.args.unset:
section.pop(self.args.option, None)
else:
section[self.args.option] = self.args.value
return 0


Expand Down
23 changes: 23 additions & 0 deletions tests/func/test_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,29 @@ def test_remote_modify_validation(dvc):
assert unsupported_config not in config[f'remote "{remote_name}"']


def test_remote_modify_unset(dvc):
assert main(["remote", "add", "-d", "myremote", "gdrive://test/test"]) == 0
config = configobj.ConfigObj(dvc.config.files["repo"])
assert config['remote "myremote"'] == {"url": "gdrive://test/test"}

assert (
main(["remote", "modify", "myremote", "gdrive_client_id", "something"])
== 0
)
config = configobj.ConfigObj(dvc.config.files["repo"])
assert config['remote "myremote"'] == {
"url": "gdrive://test/test",
"gdrive_client_id": "something",
}

assert (
main(["remote", "modify", "myremote", "gdrive_client_id", "--unset"])
== 0
)
config = configobj.ConfigObj(dvc.config.files["repo"])
assert config['remote "myremote"'] == {"url": "gdrive://test/test"}


def test_remote_modify_default(dvc):
remote_repo = "repo_level"
remote_local = "local_level"
Expand Down

0 comments on commit 72dcbc0

Please sign in to comment.