Skip to content

Commit

Permalink
Updater: check config before calling update._check
Browse files Browse the repository at this point in the history
  • Loading branch information
PuneethaPai committed Aug 4, 2020
1 parent 9c09075 commit 755e757
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 6 additions & 1 deletion dvc/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ def _with_lock(self, func, action):
logger.debug(msg.format(self.lock.lockfile, action))

def check(self):
if os.getenv("CI") or env2bool("DVC_TEST") or PKG == "snap":
if (
os.getenv("CI")
or env2bool("DVC_TEST")
or PKG == "snap"
or not self.is_enabled()
):
return

self._with_lock(self._check, "checking")
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/test_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ def test_is_enabled(dvc, updater, core, result):
assert result == updater.is_enabled()


@pytest.mark.parametrize("result", [True, False])
@mock.patch("dvc.updater.Updater._check")
def test_check_update_respect_config(mock_check, result, updater, mocker):
mocker.patch.object(updater, "is_enabled", return_value=result)
updater.check()
assert result == mock_check.called


@pytest.mark.parametrize(
"current,latest,notify",
[
Expand Down

0 comments on commit 755e757

Please sign in to comment.