MCPcopy
hub / github.com/treeverse/dvc / test_state

Function test_state

tests/func/test_state.py:8–26  ·  view source on GitHub ↗
(tmp_dir, dvc)

Source from the content-addressed store, hash-verified

6
7
8def test_state(tmp_dir, dvc):
9 tmp_dir.gen("foo", "foo content")
10 path = tmp_dir / "foo"
11 hash_info = HashInfo("md5", file_md5(path, dvc.fs))
12
13 state = State(dvc.root_dir, dvc.tmp_dir, dvc.dvcignore)
14
15 state.save(str(path), dvc.fs, hash_info)
16 assert state.get(str(path), dvc.fs)[1] == hash_info
17
18 path.unlink()
19 path.write_text("1")
20
21 assert state.get(str(path), dvc.fs) == (None, None)
22
23 hash_info = HashInfo("md5", file_md5(path, dvc.fs))
24 state.save(str(path), dvc.fs, hash_info)
25
26 assert state.get(str(path), dvc.fs)[1] == hash_info
27
28
29def test_state_overflow(tmp_dir, dvc):

Callers

nothing calls this directly

Calls 5

unlinkMethod · 0.80
write_textMethod · 0.80
genMethod · 0.45
saveMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected