Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remote: fix remote default call with no arguments #2821

Merged
merged 6 commits into from
Nov 26, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions dvc/command/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,13 @@ def run(self):

class CmdRemoteDefault(CmdRemoteConfig):
def run(self):
self.remote_config.set_default(
self.args.name, unset=self.args.unset, level=self.args.level
)
if self.args.name is None and not self.args.unset:
name = self.remote_config.get_default(level=self.args.level)
logger.info("{}".format(name))
else:
self.remote_config.set_default(
self.args.name, unset=self.args.unset, level=self.args.level
)
return 0


Expand Down
5 changes: 5 additions & 0 deletions dvc/remote/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,8 @@ def set_default(self, name, unset=False, level=None):
self.config.set(
Config.SECTION_CORE, Config.SECTION_CORE_REMOTE, name, level=level
)

def get_default(self, level=None):
return self.config.get(
Config.SECTION_CORE, Config.SECTION_CORE_REMOTE, level=level
)
6 changes: 6 additions & 0 deletions tests/func/test_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ def test(self):
self.assertEqual(default, None)


def test_show_default(caplog):
Copy link
Contributor

@efiop efiop Nov 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to remove

Suggested change
def test_show_default(caplog):
def test_show_default(dvc_repo, caplog):

as it makes the test run in the repo itself instead of in the test env. I think you've removed it because DS was complaining, but it was wrong there πŸ™‚

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right. πŸ˜„ Some tool said something about prepending the argument with unused or something like that, but I can't find the message anymore. So should I just keep the argument and let the build fail?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kaiogu Yes, DS will probably fail, but the tests themselves (run on travis) won't, so we are fine πŸ™‚

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ill accept after this dvc_repo is reintroduced. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pared Done :)

assert main(["remote", "default", "foo"]) == 0
assert main(["remote", "default"]) == 0
assert "foo" == caplog.record_tuples[0][2]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about using caplog.records[0].message?
Seems more readable than record_tuples :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obsolete after efiop comment



class TestRemoteShouldHandleUppercaseRemoteName(TestDvc):
upper_case_remote_name = "UPPERCASEREMOTE"

Expand Down