A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Catch the new error raised by redis when it can't find the broker and stub out the call for testing
Trenton H8025df5fe39f
diff --git a/src/documents/tasks.py b/src/documents/tasks.pyindex d41b19b51..667c3d9df 100644--- a/src/documents/tasks.py+++ b/src/documents/tasks.py@@ -31,6 +31,7 @@ from documents.parsers import DocumentParserfrom documents.parsers import get_parser_class_for_mime_typefrom documents.sanity_checker import SanityCheckFailedExceptionfrom filelock import FileLock+from redis.exceptions import ConnectionErrorfrom whoosh.writing import AsyncWriter@@ -157,11 +158,8 @@ def consume_file("status_updates",{"type": "status_update", "data": payload},)- except OSError as e:- logger.warning(- "OSError. It could be, the broker cannot be reached.",- )- logger.warning(str(e))+ except ConnectionError as e:+ logger.warning(f"ConnectionError on status send: {str(e)}")# consuming stops here, since the original document with# the barcodes has been split and will be consumed separatelyreturn "File successfully split"diff --git a/src/documents/tests/test_barcodes.py b/src/documents/tests/test_barcodes.pyindex c58596a1f..5de475578 100644--- a/src/documents/tests/test_barcodes.py+++ b/src/documents/tests/test_barcodes.py@@ -397,7 +397,8 @@ class TestBarcode(DirectoriesMixin, TestCase):dst = os.path.join(settings.SCRATCH_DIR, "patch-code-t-middle.pdf")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(CONSUMER_ENABLE_BARCODES=True,@@ -411,7 +412,8 @@ class TestBarcode(DirectoriesMixin, TestCase):dst = os.path.join(settings.SCRATCH_DIR, "patch-code-t-middle.tiff")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(CONSUMER_ENABLE_BARCODES=True,@@ -465,4 +467,5 @@ class TestBarcode(DirectoriesMixin, TestCase):dst = os.path.join(settings.SCRATCH_DIR, "patch-code-t-middle")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")