mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-10-06 00:00:32 +00:00
Enhancement: Add --url argument to document_fuzzy_match to improve output (#13123)
Added a new --url argument to specify the base URL of the Paperless instance, allowing matched documents to be displayed as clickable links. Updated the logic to fetch document titles based on the presence of the base URL.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import os
|
||||
from io import StringIO
|
||||
from unittest.mock import patch
|
||||
|
||||
@@ -41,7 +42,7 @@ class TestFuzzyMatchCommand(TestCase):
|
||||
|
||||
def test_invalid_ratio_upper_limit(self) -> None:
|
||||
"""
|
||||
GIVEN:s
|
||||
GIVEN:
|
||||
- Invalid ratio above upper
|
||||
WHEN:
|
||||
- Command is called
|
||||
@@ -108,6 +109,45 @@ class TestFuzzyMatchCommand(TestCase):
|
||||
stdout, _ = self.call_command("--processes", "1")
|
||||
self.assertIn("Found 1 matching pair(s)", stdout)
|
||||
|
||||
def test_with_matches_and_url(self) -> None:
|
||||
"""
|
||||
GIVEN:
|
||||
- 2 documents exist
|
||||
- Similarity between content is 86.667
|
||||
- --url is provided
|
||||
WHEN:
|
||||
- Command is called with --url
|
||||
THEN:
|
||||
- 1 match is returned from doc 1 to doc 2
|
||||
- No match from doc 2 to doc 1 reported
|
||||
- Output contains clickable links to the documents instead of titles
|
||||
"""
|
||||
# Content similarity is 86.667
|
||||
Document.objects.create(
|
||||
checksum="BEEFCAFE",
|
||||
title="A",
|
||||
content="first document scanned by bob",
|
||||
mime_type="application/pdf",
|
||||
filename="test.pdf",
|
||||
)
|
||||
Document.objects.create(
|
||||
checksum="DEADBEAF",
|
||||
title="A",
|
||||
content="first document scanned by alice",
|
||||
mime_type="application/pdf",
|
||||
filename="other_test.pdf",
|
||||
)
|
||||
with patch.dict(os.environ, {"COLUMNS": "200"}):
|
||||
stdout, _ = self.call_command(
|
||||
"--processes",
|
||||
"1",
|
||||
"--url",
|
||||
"http://localhost:8000",
|
||||
)
|
||||
self.assertIn("Found 1 matching pair(s)", stdout)
|
||||
self.assertIn("http://localhost:8000/documents/1/details", stdout)
|
||||
self.assertIn("http://localhost:8000/documents/2/details", stdout)
|
||||
|
||||
def test_with_3_matches(self) -> None:
|
||||
"""
|
||||
GIVEN:
|
||||
|
||||
Reference in New Issue
Block a user