mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-17 10:13:56 -05:00
Catch the new error raised by redis when it can't find the broker and stub out the call for testing
This commit is contained in:
parent
5aeb656a48
commit
8025df5fe3
@ -31,6 +31,7 @@ from documents.parsers import DocumentParser
|
|||||||
from documents.parsers import get_parser_class_for_mime_type
|
from documents.parsers import get_parser_class_for_mime_type
|
||||||
from documents.sanity_checker import SanityCheckFailedException
|
from documents.sanity_checker import SanityCheckFailedException
|
||||||
from filelock import FileLock
|
from filelock import FileLock
|
||||||
|
from redis.exceptions import ConnectionError
|
||||||
from whoosh.writing import AsyncWriter
|
from whoosh.writing import AsyncWriter
|
||||||
|
|
||||||
|
|
||||||
@ -157,11 +158,8 @@ def consume_file(
|
|||||||
"status_updates",
|
"status_updates",
|
||||||
{"type": "status_update", "data": payload},
|
{"type": "status_update", "data": payload},
|
||||||
)
|
)
|
||||||
except OSError as e:
|
except ConnectionError as e:
|
||||||
logger.warning(
|
logger.warning(f"ConnectionError on status send: {str(e)}")
|
||||||
"OSError. It could be, the broker cannot be reached.",
|
|
||||||
)
|
|
||||||
logger.warning(str(e))
|
|
||||||
# consuming stops here, since the original document with
|
# consuming stops here, since the original document with
|
||||||
# the barcodes has been split and will be consumed separately
|
# the barcodes has been split and will be consumed separately
|
||||||
return "File successfully split"
|
return "File successfully split"
|
||||||
|
@ -397,7 +397,8 @@ class TestBarcode(DirectoriesMixin, TestCase):
|
|||||||
dst = os.path.join(settings.SCRATCH_DIR, "patch-code-t-middle.pdf")
|
dst = os.path.join(settings.SCRATCH_DIR, "patch-code-t-middle.pdf")
|
||||||
shutil.copy(test_file, dst)
|
shutil.copy(test_file, dst)
|
||||||
|
|
||||||
self.assertEqual(tasks.consume_file(dst), "File successfully split")
|
with mock.patch("documents.tasks.async_to_sync"):
|
||||||
|
self.assertEqual(tasks.consume_file(dst), "File successfully split")
|
||||||
|
|
||||||
@override_settings(
|
@override_settings(
|
||||||
CONSUMER_ENABLE_BARCODES=True,
|
CONSUMER_ENABLE_BARCODES=True,
|
||||||
@ -411,7 +412,8 @@ class TestBarcode(DirectoriesMixin, TestCase):
|
|||||||
dst = os.path.join(settings.SCRATCH_DIR, "patch-code-t-middle.tiff")
|
dst = os.path.join(settings.SCRATCH_DIR, "patch-code-t-middle.tiff")
|
||||||
shutil.copy(test_file, dst)
|
shutil.copy(test_file, dst)
|
||||||
|
|
||||||
self.assertEqual(tasks.consume_file(dst), "File successfully split")
|
with mock.patch("documents.tasks.async_to_sync"):
|
||||||
|
self.assertEqual(tasks.consume_file(dst), "File successfully split")
|
||||||
|
|
||||||
@override_settings(
|
@override_settings(
|
||||||
CONSUMER_ENABLE_BARCODES=True,
|
CONSUMER_ENABLE_BARCODES=True,
|
||||||
@ -465,4 +467,5 @@ class TestBarcode(DirectoriesMixin, TestCase):
|
|||||||
dst = os.path.join(settings.SCRATCH_DIR, "patch-code-t-middle")
|
dst = os.path.join(settings.SCRATCH_DIR, "patch-code-t-middle")
|
||||||
shutil.copy(test_file, dst)
|
shutil.copy(test_file, dst)
|
||||||
|
|
||||||
self.assertEqual(tasks.consume_file(dst), "File successfully split")
|
with mock.patch("documents.tasks.async_to_sync"):
|
||||||
|
self.assertEqual(tasks.consume_file(dst), "File successfully split")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user