A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
update existing tests to use modified barcode api
Peter Kappeltd8d111f093b1
diff --git a/src/documents/tests/test_barcodes.py b/src/documents/tests/test_barcodes.pyindex 0c4660fed..cdaffcb3b 100644--- a/src/documents/tests/test_barcodes.py+++ b/src/documents/tests/test_barcodes.py@@ -167,18 +167,24 @@ class TestBarcode(DirectoriesMixin, TestCase):self.BARCODE_SAMPLE_DIR,"patch-code-t.pdf",)- pdf_file, separator_page_numbers = barcodes.scan_file_for_separating_barcodes(+ pdf_file, parsed_barcodes = barcodes.scan_file_for_barcodes(test_file,)+ separator_page_numbers = barcodes.get_separating_barcodes(+ parsed_barcodes,+ )self.assertEqual(pdf_file, test_file)self.assertListEqual(separator_page_numbers, [0])def test_scan_file_for_separating_barcodes_none_present(self):test_file = os.path.join(self.SAMPLE_DIR, "simple.pdf")- pdf_file, separator_page_numbers = barcodes.scan_file_for_separating_barcodes(+ pdf_file, parsed_barcodes = barcodes.scan_file_for_barcodes(test_file,)+ separator_page_numbers = barcodes.get_separating_barcodes(+ parsed_barcodes,+ )self.assertEqual(pdf_file, test_file)self.assertListEqual(separator_page_numbers, [])@@ -188,9 +194,12 @@ class TestBarcode(DirectoriesMixin, TestCase):self.BARCODE_SAMPLE_DIR,"patch-code-t-middle.pdf",)- pdf_file, separator_page_numbers = barcodes.scan_file_for_separating_barcodes(+ pdf_file, parsed_barcodes = barcodes.scan_file_for_barcodes(test_file,)+ separator_page_numbers = barcodes.get_separating_barcodes(+ parsed_barcodes,+ )self.assertEqual(pdf_file, test_file)self.assertListEqual(separator_page_numbers, [1])@@ -200,9 +209,12 @@ class TestBarcode(DirectoriesMixin, TestCase):self.BARCODE_SAMPLE_DIR,"several-patcht-codes.pdf",)- pdf_file, separator_page_numbers = barcodes.scan_file_for_separating_barcodes(+ pdf_file, parsed_barcodes = barcodes.scan_file_for_barcodes(test_file,)+ separator_page_numbers = barcodes.get_separating_barcodes(+ parsed_barcodes,+ )self.assertEqual(pdf_file, test_file)self.assertListEqual(separator_page_numbers, [2, 5])@@ -212,14 +224,17 @@ class TestBarcode(DirectoriesMixin, TestCase):self.BARCODE_SAMPLE_DIR,"patch-code-t-middle_reverse.pdf",)- pdf_file, separator_page_numbers = barcodes.scan_file_for_separating_barcodes(+ pdf_file, parsed_barcodes = barcodes.scan_file_for_barcodes(test_file,)+ separator_page_numbers = barcodes.get_separating_barcodes(+ parsed_barcodes,+ )self.assertEqual(pdf_file, test_file)self.assertListEqual(separator_page_numbers, [1])- def test_scan_file_for_separating_barcodes_pillow_transcode_error(self):+ def test_scan_file_for_barcodes_pillow_transcode_error(self):"""GIVEN:- A PDF containing an image which cannot be transcoded to a PIL image@@ -273,7 +288,7 @@ class TestBarcode(DirectoriesMixin, TestCase):with mock.patch("documents.barcodes.barcode_reader") as reader:reader.return_value = list()- _, _ = barcodes.scan_file_for_separating_barcodes(+ _, _ = barcodes.scan_file_for_barcodes(str(device_n_pdf.name),)@@ -292,9 +307,12 @@ class TestBarcode(DirectoriesMixin, TestCase):self.BARCODE_SAMPLE_DIR,"barcode-fax-image.pdf",)- pdf_file, separator_page_numbers = barcodes.scan_file_for_separating_barcodes(+ pdf_file, parsed_barcodes = barcodes.scan_file_for_barcodes(test_file,)+ separator_page_numbers = barcodes.get_separating_barcodes(+ parsed_barcodes,+ )self.assertEqual(pdf_file, test_file)self.assertListEqual(separator_page_numbers, [1])@@ -304,9 +322,12 @@ class TestBarcode(DirectoriesMixin, TestCase):self.BARCODE_SAMPLE_DIR,"patch-code-t-qr.pdf",)- pdf_file, separator_page_numbers = barcodes.scan_file_for_separating_barcodes(+ pdf_file, parsed_barcodes = barcodes.scan_file_for_barcodes(test_file,)+ separator_page_numbers = barcodes.get_separating_barcodes(+ parsed_barcodes,+ )self.assertEqual(pdf_file, test_file)self.assertListEqual(separator_page_numbers, [0])@@ -317,9 +338,12 @@ class TestBarcode(DirectoriesMixin, TestCase):self.BARCODE_SAMPLE_DIR,"barcode-39-custom.pdf",)- pdf_file, separator_page_numbers = barcodes.scan_file_for_separating_barcodes(+ pdf_file, parsed_barcodes = barcodes.scan_file_for_barcodes(test_file,)+ separator_page_numbers = barcodes.get_separating_barcodes(+ parsed_barcodes,+ )self.assertEqual(pdf_file, test_file)self.assertListEqual(separator_page_numbers, [0])@@ -330,9 +354,12 @@ class TestBarcode(DirectoriesMixin, TestCase):self.BARCODE_SAMPLE_DIR,"barcode-qr-custom.pdf",)- pdf_file, separator_page_numbers = barcodes.scan_file_for_separating_barcodes(+ pdf_file, parsed_barcodes = barcodes.scan_file_for_barcodes(test_file,)+ separator_page_numbers = barcodes.get_separating_barcodes(+ parsed_barcodes,+ )self.assertEqual(pdf_file, test_file)self.assertListEqual(separator_page_numbers, [0])@@ -343,9 +370,12 @@ class TestBarcode(DirectoriesMixin, TestCase):self.BARCODE_SAMPLE_DIR,"barcode-128-custom.pdf",)- pdf_file, separator_page_numbers = barcodes.scan_file_for_separating_barcodes(+ pdf_file, parsed_barcodes = barcodes.scan_file_for_barcodes(test_file,)+ separator_page_numbers = barcodes.get_separating_barcodes(+ parsed_barcodes,+ )self.assertEqual(pdf_file, test_file)self.assertListEqual(separator_page_numbers, [0])@@ -355,9 +385,12 @@ class TestBarcode(DirectoriesMixin, TestCase):self.BARCODE_SAMPLE_DIR,"barcode-39-custom.pdf",)- pdf_file, separator_page_numbers = barcodes.scan_file_for_separating_barcodes(+ pdf_file, parsed_barcodes = barcodes.scan_file_for_barcodes(test_file,)+ separator_page_numbers = barcodes.get_separating_barcodes(+ parsed_barcodes,+ )self.assertEqual(pdf_file, test_file)self.assertListEqual(separator_page_numbers, [])@@ -450,9 +483,12 @@ class TestBarcode(DirectoriesMixin, TestCase):)tempdir = tempfile.mkdtemp(prefix="paperless-", dir=settings.SCRATCH_DIR)- pdf_file, separator_page_numbers = barcodes.scan_file_for_separating_barcodes(+ pdf_file, parsed_barcodes = barcodes.scan_file_for_barcodes(test_file,)+ separator_page_numbers = barcodes.get_separating_barcodes(+ parsed_barcodes,+ )self.assertEqual(test_file, pdf_file)self.assertTrue(len(separator_page_numbers) > 0)@@ -562,9 +598,12 @@ class TestBarcode(DirectoriesMixin, TestCase):- Scanning handle the exception without exception"""test_file = os.path.join(self.SAMPLE_DIR, "password-is-test.pdf")- pdf_file, separator_page_numbers = barcodes.scan_file_for_separating_barcodes(+ pdf_file, parsed_barcodes = barcodes.scan_file_for_barcodes(test_file,)+ separator_page_numbers = barcodes.get_separating_barcodes(+ parsed_barcodes,+ )self.assertEqual(pdf_file, test_file)self.assertListEqual(separator_page_numbers, [])