Partially Revert "Chore(deps): Bump the small-changes group across 1 directory with 6 updates (#9921)"

This partially reverts commit 1fe166e014.
This commit is contained in:
shamoon
2025-05-19 12:15:57 -07:00
parent ba80790826
commit 0b079f57ed
6 changed files with 1617 additions and 1626 deletions

View File

@@ -125,14 +125,14 @@ class Command(MultiProcessMixin, ProgressBarMixin, BaseCommand):
messages.append(
self.style.NOTICE(
f"Document {result.doc_one_pk} fuzzy match"
f" to {result.doc_two_pk} (confidence {result.ratio:.3f})\n",
f" to {result.doc_two_pk} (confidence {result.ratio:.3f})",
),
)
maybe_delete_ids.append(result.doc_two_pk)
if len(messages) == 0:
messages.append(
self.style.SUCCESS("No matches found\n"),
self.style.SUCCESS("No matches found"),
)
self.stdout.writelines(
messages,

View File

@@ -87,7 +87,7 @@ class TestFuzzyMatchCommand(TestCase):
filename="other_test.pdf",
)
stdout, _ = self.call_command()
self.assertIn("No matches found", stdout)
self.assertEqual(stdout, "No matches found\n")
def test_with_matches(self):
"""
@@ -116,7 +116,7 @@ class TestFuzzyMatchCommand(TestCase):
filename="other_test.pdf",
)
stdout, _ = self.call_command("--processes", "1")
self.assertRegex(stdout, self.MSG_REGEX)
self.assertRegex(stdout, self.MSG_REGEX + "\n")
def test_with_3_matches(self):
"""
@@ -152,10 +152,11 @@ class TestFuzzyMatchCommand(TestCase):
filename="final_test.pdf",
)
stdout, _ = self.call_command()
lines = [x.strip() for x in stdout.splitlines() if x.strip()]
lines = [x.strip() for x in stdout.split("\n") if len(x.strip())]
self.assertEqual(len(lines), 3)
for line in lines:
self.assertRegex(line, self.MSG_REGEX)
self.assertRegex(lines[0], self.MSG_REGEX)
self.assertRegex(lines[1], self.MSG_REGEX)
self.assertRegex(lines[2], self.MSG_REGEX)
def test_document_deletion(self):
"""
@@ -196,12 +197,14 @@ class TestFuzzyMatchCommand(TestCase):
stdout, _ = self.call_command("--delete")
self.assertIn(
lines = [x.strip() for x in stdout.split("\n") if len(x.strip())]
self.assertEqual(len(lines), 3)
self.assertEqual(
lines[0],
"The command is configured to delete documents. Use with caution",
stdout,
)
self.assertRegex(stdout, self.MSG_REGEX)
self.assertIn("Deleting 1 documents based on ratio matches", stdout)
self.assertRegex(lines[1], self.MSG_REGEX)
self.assertEqual(lines[2], "Deleting 1 documents based on ratio matches")
self.assertEqual(Document.objects.count(), 2)
self.assertIsNotNone(Document.objects.get(pk=1))

View File

@@ -54,7 +54,7 @@ class HttpRemoteUserMiddleware(PersistentRemoteUserMiddleware):
header = settings.HTTP_REMOTE_USER_HEADER_NAME
def __call__(self, request: HttpRequest) -> None:
def process_request(self, request: HttpRequest) -> None:
# If remote user auth is enabled only for the frontend, not the API,
# then we need dont want to authenticate the user for API requests.
if (
@@ -62,8 +62,8 @@ class HttpRemoteUserMiddleware(PersistentRemoteUserMiddleware):
and "paperless.auth.PaperlessRemoteUserAuthentication"
not in settings.REST_FRAMEWORK["DEFAULT_AUTHENTICATION_CLASSES"]
):
return self.get_response(request)
return super().__call__(request)
return
return super().process_request(request)
class PaperlessRemoteUserAuthentication(authentication.RemoteUserAuthentication):

View File

@@ -1,7 +1,6 @@
import os
from unittest import mock
from django.conf import settings
from django.contrib.auth.models import User
from django.test import override_settings
from rest_framework import status
@@ -92,7 +91,6 @@ class TestRemoteUser(DirectoriesMixin, APITestCase):
@override_settings(
REST_FRAMEWORK={
**settings.REST_FRAMEWORK,
"DEFAULT_AUTHENTICATION_CLASSES": [
"rest_framework.authentication.BasicAuthentication",
"rest_framework.authentication.TokenAuthentication",