mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-10 07:18:27 +01:00
* remote: locally index list of checksums available on cloud remotes * fix review issues - use pytest fixtures - use sha256 digest - s/fd/fobj/ - check more specific IO errors * remote: use .dir checksums to validate index * command: add --drop-index option for push/pull/status * tests: --drop-index unit tests * remote: make index threadsafe * remote: force re-index after gc * only save/dump index once per command * remote: add helper index functions update_all/replace_all * remote: store index as sqlite3 database * fix deepsource warnings * rename --drop-index to --clear-index * rename index.invalidate to index.clear * functional tests for remote.index * fix index not being updated on status -c * remote: add index.intersection() * remote: use index when making assumptions about remote .dir contents * add missing func tests * do not index standalone files * cleanup index test fixture * fix deepsource warnings * update autocompletion scripts/cli help message for --clear-index * tests: remove unused mocker * push: only index successfully pushed dirs - do not index files on partial push/upload * remote: revert behavior to trust .dir files on remote - skip unnecessary index check for dir contents if .dir file exists on the remote * fix missing RemoteIndexNoop functions * separate index validation from status dir exists query * bugfix: include indexed checksums for all cache_exists cases * review fix: cleanup debug messages * tests: fix DS warning * remove --clear-index * remove unused index functions
58 lines
1.4 KiB
Python
58 lines
1.4 KiB
Python
import os
|
|
|
|
import pytest
|
|
from funcy import first
|
|
|
|
from dvc.remote.index import RemoteIndex
|
|
|
|
|
|
@pytest.fixture(scope="function")
|
|
def index(dvc):
|
|
index = RemoteIndex(dvc, "foo")
|
|
index.load()
|
|
yield index
|
|
index.dump()
|
|
os.unlink(index.path)
|
|
|
|
|
|
def test_init(dvc, index):
|
|
assert str(index.path) == os.path.join(dvc.index_dir, "foo.idx")
|
|
|
|
|
|
def test_is_dir_checksum(dvc, index):
|
|
assert index.is_dir_checksum("foo.dir")
|
|
assert not index.is_dir_checksum("foo")
|
|
|
|
|
|
def test_roundtrip(dvc, index):
|
|
expected_dir = {"1234.dir"}
|
|
expected_file = {"5678"}
|
|
index.update(expected_dir, expected_file)
|
|
index.dump()
|
|
index.load()
|
|
assert set(index.dir_checksums()) == expected_dir
|
|
assert set(index.checksums()) == expected_dir | expected_file
|
|
|
|
|
|
def test_clear(dvc, index):
|
|
index.update(
|
|
["1234.dir"], ["5678"],
|
|
)
|
|
index.clear()
|
|
assert first(index.checksums()) is None
|
|
|
|
|
|
def test_update(dvc, index):
|
|
expected_dir = {"1234.dir"}
|
|
expected_file = {"5678"}
|
|
index.update(expected_dir, expected_file)
|
|
assert set(index.dir_checksums()) == expected_dir
|
|
assert set(index.checksums()) == expected_dir | expected_file
|
|
|
|
|
|
def test_intersection(dvc, index):
|
|
checksums = (str(i) for i in range(2000))
|
|
expected = {str(i) for i in range(1000)}
|
|
index.update([], checksums)
|
|
assert set(index.intersection(expected)) == expected
|