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

Method test_filesystem

dvc/testing/api_tests.py:44–129  ·  view source on GitHub ↗
(
        self,
        tmp_dir,
        make_tmp_dir,
        scm,
        dvc,
        remote,
        fs_kwargs,
        clear_cache,
    )

Source from the content-addressed store, hash-verified

42 ids=["current", "local", "local_rev", "git", "git_rev", "local_url"],
43 )
44 def test_filesystem(
45 self,
46 tmp_dir,
47 make_tmp_dir,
48 scm,
49 dvc,
50 remote,
51 fs_kwargs,
52 clear_cache,
53 ):
54 fs_kwargs = fs_kwargs.copy()
55
56 tmp_dir.scm_gen({"scripts": {"script1": "script1"}}, commit="scripts")
57 tmp_dir.dvc_gen({"data": {"foo": "foo", "bar": "bar"}}, commit="data")
58 dvc.push()
59
60 if clear_cache:
61 remove(dvc.cache.repo.path)
62
63 if repo := fs_kwargs.get("repo"):
64 fs_kwargs["repo"] = repo.format(path=tmp_dir, posixpath=tmp_dir.as_posix())
65 if url := fs_kwargs.get("url"):
66 fs_kwargs["url"] = url.format(path=tmp_dir, posixpath=tmp_dir.as_posix())
67 if rev := fs_kwargs.get("rev"):
68 fs_kwargs["rev"] = rev.format(default_branch=scm.active_branch())
69
70 fs = DVCFileSystem(**fs_kwargs)
71
72 assert fs.ls("/", detail=False) == M.unordered(
73 "/.gitignore", "/scripts", "/data"
74 )
75 assert fs.ls("scripts", detail=False) == ["scripts/script1"]
76 assert fs.ls("data", detail=False) == M.unordered("data/foo", "data/bar")
77
78 data_info = M.dict(
79 name="/data",
80 type="directory",
81 dvc_info=M.dict(isdvc=True, isout=True),
82 )
83 scripts_info = M.dict(name="/scripts", type="directory", isexec=False)
84
85 assert sorted(fs.ls("/"), key=lambda i: i["name"]) == [
86 M.dict(name="/.gitignore", type="file", isexec=False),
87 data_info,
88 scripts_info,
89 ]
90
91 with pytest.raises(FileNotFoundError):
92 fs.info("/not-existing-path")
93
94 assert fs.info("/") == M.dict(name="/", isexec=False, type="directory")
95 assert fs.info("/data") == data_info
96 assert fs.info("/scripts") == scripts_info
97 assert fs.info("/data/foo") == M.dict(name="/data/foo", type="file")
98 assert fs.info("/scripts/script1") == M.dict(
99 name="/scripts/script1", type="file"
100 )
101

Callers

nothing calls this directly

Calls 15

getMethod · 0.95
isdvcMethod · 0.95
removeFunction · 0.90
DVCFileSystemClass · 0.85
make_tmp_dirFunction · 0.85
scm_genMethod · 0.80
dvc_genMethod · 0.80
as_posixMethod · 0.80
openMethod · 0.80
get_fileMethod · 0.80
pushMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected