Files
dvc/tests/func/test_unprotect.py
T
Ruslan Kuprieiev 58295ca0ab repo: rename odb -> cache
We used to have it named `cache` before, but these days it is clear that
you can have three odbs: just odb (e.g. in-memory), cache (typically local)
or remote (typically cloud). Fixing naming here before proceeding with
introducing `out.odb` and `out.cache`.

In preparation for migration to https://github.com/iterative/dvc-data/pull/304
2023-02-08 23:05:45 +02:00

26 lines
830 B
Python

import os
def test_unprotect(tmp_dir, dvc):
tmp_dir.gen("foo", "foo")
dvc.cache.local.cache_types = ["hardlink"]
dvc.add("foo")
cache = os.path.join(".dvc", "cache", "ac", "bd18db4cc2f85cedef654fccc4a4d8")
assert not os.access("foo", os.W_OK)
assert not os.access(cache, os.W_OK)
dvc.unprotect("foo")
assert os.access("foo", os.W_OK)
if os.name == "nt":
# NOTE: cache is now unprotected, because NTFS doesn't allow
# deleting read-only files, so we have to try to set write perms
# on files that we try to delete, which propagates to the cache
# file. But it should be restored after the next cache check, hence
# why we call `dvc status` here.
assert os.access(cache, os.W_OK)
dvc.status()
assert not os.access(cache, os.W_OK)