def test_get_hash_granular(tmp_dir, dvc): tmp_dir.dvc_gen( {"dir": {"foo": "foo", "bar": "bar", "subdir": {"data": "data"}}} ) tree = DvcTree(dvc, fetch=True) subdir = PathInfo(tmp_dir) / "dir" / "subdir" assert tree.get_hash(subdir) == ( "md5", "af314506f1622d107e0ed3f14ec1a3b5.dir", ) assert tree.get_hash(subdir / "data") == ( "md5", "8d777f385d3dfec8815d20f7496026dc", )
def test_get_hash_file(tmp_dir, dvc): tmp_dir.dvc_gen({"foo": "foo"}) tree = DvcTree(dvc) assert tree.get_hash(PathInfo(tmp_dir) / "foo") == HashInfo( "md5", "acbd18db4cc2f85cedef654fccc4a4d8", )
def test_get_hash_dirty_file(tmp_dir, dvc): tmp_dir.dvc_gen("file", "file") (tmp_dir / "file").write_text("something") tree = DvcTree(dvc) actual = tree.get_hash(PathInfo(tmp_dir) / "file") expected = HashInfo("md5", "8c7dd922ad47494fc02c388e12c00eac") assert actual == expected
def test_get_hash_dirty_dir(tmp_dir, dvc): tmp_dir.dvc_gen({"dir": {"foo": "foo", "bar": "bar"}}) (tmp_dir / "dir" / "baz").write_text("baz") tree = DvcTree(dvc) actual = tree.get_hash(PathInfo(tmp_dir) / "dir") expected = HashInfo("md5", "5ea40360f5b4ec688df672a4db9c17d1.dir") assert actual == expected
def test_get_hash_dir(tmp_dir, dvc, mocker): tmp_dir.dvc_gen( {"dir": {"foo": "foo", "bar": "bar", "subdir": {"data": "data"}}} ) tree = DvcTree(dvc) get_file_hash_spy = mocker.spy(tree, "get_file_hash") assert tree.get_hash(PathInfo(tmp_dir) / "dir") == ( "md5", "8761c4e9acad696bee718615e23e22db.dir", ) assert not get_file_hash_spy.called