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

Function test_is_protected

tests/unit/data/db/test_local.py:34–62  ·  view source on GitHub ↗
(tmp_dir, dvc, link_name)

Source from the content-addressed store, hash-verified

32
33@pytest.mark.parametrize("link_name", ["hardlink", "symlink"])
34def test_is_protected(tmp_dir, dvc, link_name):
35 odb = dvc.cache.local
36 fs = odb.fs
37 link_method = getattr(fs, link_name)
38
39 (tmp_dir / "foo").write_text("foo")
40
41 foo = tmp_dir / "foo"
42 link = tmp_dir / "link"
43
44 link_method(foo, link)
45
46 assert not odb.is_protected(foo)
47 assert not odb.is_protected(link)
48
49 odb.protect(foo)
50
51 assert odb.is_protected(foo)
52 assert odb.is_protected(link)
53
54 odb.unprotect(link)
55
56 assert not odb.is_protected(link)
57 if os.name == "nt" and link_name == "hardlink":
58 # NOTE: NTFS doesn't allow deleting read-only files, which forces us to
59 # set write perms on the link, which propagates to the source.
60 assert not odb.is_protected(foo)
61 else:
62 assert odb.is_protected(foo)
63
64
65@pytest.mark.parametrize("err", [errno.EPERM, errno.EACCES, errno.EROFS])

Callers

nothing calls this directly

Calls 4

write_textMethod · 0.80
is_protectedMethod · 0.80
protectMethod · 0.80
unprotectMethod · 0.45

Tested by

no test coverage detected