mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-28 18:24:38 -05:00
add TIFF barcode support
Signed-off-by: Florian Brandes <florian.brandes@posteo.de>
This commit is contained in:
BIN
src/documents/tests/samples/barcodes/patch-code-t-middle.tiff
Normal file
BIN
src/documents/tests/samples/barcodes/patch-code-t-middle.tiff
Normal file
Binary file not shown.
BIN
src/documents/tests/samples/simple.tiff
Normal file
BIN
src/documents/tests/samples/simple.tiff
Normal file
Binary file not shown.
@@ -204,6 +204,30 @@ class TestTasks(DirectoriesMixin, TestCase):
|
||||
img = Image.open(test_file)
|
||||
self.assertEqual(tasks.barcode_reader(img), ["CUSTOM BARCODE"])
|
||||
|
||||
def test_convert_from_tiff_to_pdf(self):
|
||||
test_file = os.path.join(
|
||||
os.path.dirname(__file__),
|
||||
"samples",
|
||||
"simple.tiff",
|
||||
)
|
||||
dst = os.path.join(settings.SCRATCH_DIR, "simple.tiff")
|
||||
shutil.copy(test_file, dst)
|
||||
target_file = tasks.convert_from_tiff_to_pdf(dst)
|
||||
file_extension = os.path.splitext(os.path.basename(target_file))[1]
|
||||
self.assertTrue(os.path.isfile(target_file))
|
||||
self.assertEqual(file_extension, ".pdf")
|
||||
|
||||
def test_convert_error_from_pdf_to_pdf(self):
|
||||
test_file = os.path.join(
|
||||
os.path.dirname(__file__),
|
||||
"samples",
|
||||
"simple.pdf",
|
||||
)
|
||||
dst = os.path.join(settings.SCRATCH_DIR, "simple.pdf")
|
||||
shutil.copy(test_file, dst)
|
||||
target_file = tasks.convert_from_tiff_to_pdf(dst)
|
||||
self.assertFalse(os.path.isfile(target_file))
|
||||
|
||||
def test_scan_file_for_separating_barcodes(self):
|
||||
test_file = os.path.join(
|
||||
os.path.dirname(__file__),
|
||||
@@ -400,7 +424,23 @@ class TestTasks(DirectoriesMixin, TestCase):
|
||||
"barcodes",
|
||||
"patch-code-t-middle.pdf",
|
||||
)
|
||||
dst = os.path.join(settings.SCRATCH_DIR, "patch-code-t-middle.pd")
|
||||
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")
|
||||
|
||||
@override_settings(
|
||||
CONSUMER_ENABLE_BARCODES=True,
|
||||
CONSUMER_BARCODE_TIFF_SUPPORT=True,
|
||||
)
|
||||
def test_consume_barcode_tiff_file(self):
|
||||
test_file = os.path.join(
|
||||
os.path.dirname(__file__),
|
||||
"samples",
|
||||
"barcodes",
|
||||
"patch-code-t-middle.tiff",
|
||||
)
|
||||
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")
|
||||
|
Reference in New Issue
Block a user