mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-10-07 16:47:13 +00:00
Chore: Make the sample duplicate guard fail on a missing tree
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4ffe71c568
commit
a978b9dd8e
1 file changed
+4
-2
@@ -39,7 +39,6 @@ def test_install_uses_the_shared_bytes(tmp_path: Path) -> None:
|
||||
APP_SAMPLE_TREES = [
|
||||
Path(__file__).parent / "samples",
|
||||
Path(__file__).parents[2] / "paperless" / "tests" / "samples",
|
||||
Path(__file__).parent / "examples",
|
||||
SHARED_SAMPLES_DIR,
|
||||
]
|
||||
|
||||
@@ -47,9 +46,12 @@ APP_SAMPLE_TREES = [
|
||||
def test_no_two_sample_files_have_identical_bytes() -> None:
|
||||
by_hash: dict[str, list[Path]] = defaultdict(list)
|
||||
for tree in APP_SAMPLE_TREES:
|
||||
assert tree.is_dir(), f"Sample tree does not exist: {tree}"
|
||||
for path in tree.rglob("*"):
|
||||
if path.is_file():
|
||||
# Skip empty placeholders, which would all hash identically
|
||||
if path.is_file() and path.stat().st_size > 0:
|
||||
by_hash[_sha(path)].append(path)
|
||||
assert by_hash, "No sample files were found to compare"
|
||||
duplicates = {h: ps for h, ps in by_hash.items() if len(ps) > 1}
|
||||
lines = [" " + ", ".join(str(p) for p in ps) for ps in duplicates.values()]
|
||||
message = (
|
||||
|
||||
Reference in new issue
Block a user