コード例 #1
0
def test_is_protected(tmp_dir, dvc, link_name):
    remote = RemoteLOCAL(dvc, {})
    link_method = getattr(remote, link_name)

    (tmp_dir / "foo").write_text("foo")

    foo = PathInfo(tmp_dir / "foo")
    link = PathInfo(tmp_dir / "link")

    link_method(foo, link)

    assert not remote.is_protected(foo)
    assert not remote.is_protected(link)

    remote.protect(foo)

    assert remote.is_protected(foo)
    assert remote.is_protected(link)

    remote.unprotect(link)

    assert not remote.is_protected(link)
    if os.name == "nt" and link_name == "hardlink":
        # NOTE: NTFS doesn't allow deleting read-only files, which forces us to
        # set write perms on the link, which propagates to the source.
        assert not remote.is_protected(foo)
    else:
        assert remote.is_protected(foo)
コード例 #2
0
def test_is_protected(tmp_dir, link_name):
    remote = RemoteLOCAL(None, {})
    link_method = getattr(remote, link_name)

    (tmp_dir / "foo").write_text("foo")

    foo = PathInfo(tmp_dir / "foo")
    link = PathInfo(tmp_dir / "link")

    link_method(foo, link)

    assert not remote.is_protected(foo)
    assert not remote.is_protected(link)

    remote.protect(foo)

    assert remote.is_protected(foo)
    assert remote.is_protected(link)

    remote.unprotect(link)

    assert not remote.is_protected(link)
    if link_name == "symlink" and os.name == "nt":
        # NOTE: Windows symlink perms don't propagate to the target
        assert remote.is_protected(foo)
    else:
        assert not remote.is_protected(foo)