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

Function test_data_index

tests/func/test_repo_index.py:335–405  ·  view source on GitHub ↗
(tmp_dir, dvc, local_cloud, erepo_dir)

Source from the content-addressed store, hash-verified

333
334
335def test_data_index(tmp_dir, dvc, local_cloud, erepo_dir):
336 tmp_dir.dvc_gen({"foo": b"foo", "dir": {"bar": b"bar", "subdir": {"baz": b"baz"}}})
337
338 with erepo_dir.chdir():
339 erepo_dir.dvc_gen("efoo", b"efoo", commit="create efoo")
340 erepo_dir.dvc_gen(
341 "edir",
342 {"ebar": b"ebar", "esubdir": {"ebaz": b"ebaz"}},
343 commit="create edir",
344 )
345
346 dvc.imp(os.fspath(erepo_dir), "efoo")
347 dvc.imp(os.fspath(erepo_dir), "edir")
348
349 dvc.imp(os.fspath(erepo_dir), "efoo", "efoo_partial", no_download=True)
350 dvc.imp(os.fspath(erepo_dir), "edir", "edir_partial", no_download=True)
351
352 local_cloud.gen("ifoo", b"ifoo")
353 local_cloud.gen("idir", {"ibar": b"ibar", "isubdir": {"ibaz": b"ibaz"}})
354
355 dvc.imp_url(str(local_cloud / "ifoo"))
356 dvc.imp_url(str(local_cloud / "idir"))
357
358 dvc.imp_url(str(local_cloud / "ifoo"), "ifoo_partial", no_download=True)
359 dvc.imp_url(str(local_cloud / "idir"), "idir_partial", no_download=True)
360
361 index = Index.from_repo(dvc)
362 assert index.data_keys == {
363 "local": set(),
364 "repo": {
365 ("foo",),
366 ("dir",),
367 ("efoo",),
368 ("edir",),
369 ("efoo_partial",),
370 ("edir_partial",),
371 ("ifoo",),
372 ("idir",),
373 ("ifoo_partial",),
374 ("idir_partial",),
375 },
376 }
377
378 data = index.data["repo"]
379 assert set(data.keys()) == {
380 ("foo",),
381 ("dir",),
382 ("efoo",),
383 ("edir",),
384 ("efoo_partial",),
385 ("edir_partial",),
386 ("ifoo",),
387 ("idir",),
388 ("ifoo_partial",),
389 ("idir_partial",),
390 }
391
392 assert not data.storage_map[("foo",)].remote

Callers

nothing calls this directly

Calls 6

dvc_genMethod · 0.80
keysMethod · 0.80
chdirMethod · 0.45
fspathMethod · 0.45
genMethod · 0.45
from_repoMethod · 0.45

Tested by

no test coverage detected