(tmp_dir, dvc, link_name)
| 32 | |
| 33 | @pytest.mark.parametrize("link_name", ["hardlink", "symlink"]) |
| 34 | def 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]) |
nothing calls this directly
no test coverage detected