forked from iterative/dvc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_utils.py
44 lines (34 loc) · 1.06 KB
/
test_utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# encoding: utf-8
from dvc import utils
def test_file_md5_crlf(tmp_dir):
tmp_dir.gen("cr", b"a\nb\nc")
tmp_dir.gen("crlf", b"a\r\nb\r\nc")
assert utils.file_md5("cr")[0] == utils.file_md5("crlf")[0]
def test_dict_md5():
d = {
"cmd": "python code.py foo file1",
"locked": "true",
"outs": [
{
"path": "file1",
"metric": {"type": "raw"},
"cache": False,
"md5": "acbd18db4cc2f85cedef654fccc4a4d8",
}
],
"deps": [
{"path": "foo", "md5": "acbd18db4cc2f85cedef654fccc4a4d8"},
{"path": "code.py", "md5": "d05447644b89960913c7eee5fd776adb"},
],
}
md5 = "8b263fa05ede6c3145c164829be694b4"
assert md5 == utils.dict_md5(d, exclude=["metric", "locked"])
def test_boxify():
expected = (
"+-----------------+\n"
"| |\n"
"| message |\n"
"| |\n"
"+-----------------+\n"
)
assert expected == utils.boxify("message")