mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-12-03 07:18:28 +01:00
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:
@@ -0,0 +1,40 @@
|
||||
from collections import OrderedDict
|
||||
|
||||
from dvc.utils.humanize import get_summary
|
||||
|
||||
|
||||
def test_get_summary():
|
||||
# dict, so that we could delete from it easily
|
||||
stats = OrderedDict(
|
||||
[
|
||||
("fetched", 3),
|
||||
("added", ["file1", "file2", "file3"]),
|
||||
("deleted", ["file4", "file5"]),
|
||||
("modified", ["file6", "file7"]),
|
||||
]
|
||||
)
|
||||
|
||||
assert get_summary(stats.items()) == (
|
||||
"3 files fetched, "
|
||||
"3 files added, "
|
||||
"2 files deleted "
|
||||
"and "
|
||||
"2 files modified"
|
||||
)
|
||||
|
||||
del stats["fetched"]
|
||||
del stats["deleted"][1]
|
||||
assert (
|
||||
get_summary(stats.items())
|
||||
== "3 files added, 1 file deleted and 2 files modified"
|
||||
)
|
||||
|
||||
del stats["deleted"][0]
|
||||
assert get_summary(stats.items()) == "3 files added and 2 files modified"
|
||||
|
||||
del stats["modified"]
|
||||
assert get_summary(stats.items()) == "3 files added"
|
||||
|
||||
assert get_summary([]) == ""
|
||||
assert get_summary([("x", 0), ("y", [])]) == ""
|
||||
assert get_summary([("x", 1), ("y", [])]) == "1 file x"
|
||||
Reference in New Issue
Block a user