pull/fetch/push: add stats (#3735)

* pull/fetch/push: add stats

* fix typo: s/logging/logger

* pull: make stats detailed, with summary at the bottom

* tests: mock properly, set return_value

* add a line space
This commit is contained in:
Saugat Pachhai
2020-05-05 16:10:50 +03:00
committed by GitHub
parent 795f001929
commit d00bd4dfe5
9 changed files with 149 additions and 72 deletions
+1 -28
View File
@@ -1,7 +1,7 @@
import logging
from dvc.cli import parse_args
from dvc.command.checkout import CmdCheckout, log_summary, log_changes
from dvc.command.checkout import CmdCheckout, log_changes
def test_checkout(tmp_dir, dvc, mocker):
@@ -23,33 +23,6 @@ def test_checkout(tmp_dir, dvc, mocker):
)
def test_log_summary(caplog):
stats = {
"added": ["file1", "file2", "file3"],
"deleted": ["file4", "file5"],
"modified": ["file6", "file7"],
}
def _assert_output(stats, expected_text):
with caplog.at_level(logging.INFO, logger="dvc"):
caplog.clear()
log_summary(stats)
assert expected_text in caplog.text
_assert_output(stats, "3 added, 2 deleted and 2 modified")
del stats["deleted"][1]
_assert_output(stats, "3 added, 1 deleted and 2 modified")
del stats["deleted"][0]
_assert_output(stats, "3 added and 2 modified")
del stats["modified"]
_assert_output(stats, "3 added")
_assert_output({}, "No changes.")
def test_log_changes(caplog):
stats = {
"added": ["file1", "dir1/"],
+2 -2
View File
@@ -22,7 +22,7 @@ def test_fetch(mocker):
assert cli_args.func == CmdDataFetch
cmd = cli_args.func(cli_args)
m = mocker.patch.object(cmd.repo, "fetch", autospec=True)
m = mocker.patch.object(cmd.repo, "fetch", autospec=True, return_value=0)
assert cmd.run() == 0
@@ -96,7 +96,7 @@ def test_push(mocker):
assert cli_args.func == CmdDataPush
cmd = cli_args.func(cli_args)
m = mocker.patch.object(cmd.repo, "push", autospec=True)
m = mocker.patch.object(cmd.repo, "push", autospec=True, return_value=0)
assert cmd.run() == 0