mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-09 09:58:20 -05:00
Changes the simple-alpha parsing test to use a tempdir so the original isn't modified in Git
This commit is contained in:
parent
ec045e81f2
commit
49a843dcdd
@ -1,4 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
|
import tempfile
|
||||||
import uuid
|
import uuid
|
||||||
from typing import ContextManager
|
from typing import ContextManager
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
@ -225,11 +227,18 @@ class TestParser(DirectoriesMixin, TestCase):
|
|||||||
def test_image_simple_alpha(self):
|
def test_image_simple_alpha(self):
|
||||||
parser = RasterisedDocumentParser(None)
|
parser = RasterisedDocumentParser(None)
|
||||||
|
|
||||||
parser.parse(os.path.join(self.SAMPLE_FILES, "simple-alpha.png"), "image/png")
|
with tempfile.TemporaryDirectory() as tempdir:
|
||||||
|
# Copy sample file to temp directory, as the parsing changes the file
|
||||||
|
# and this makes it modified to Git
|
||||||
|
sample_file = os.path.join(self.SAMPLE_FILES, "simple-alpha.png")
|
||||||
|
dest_file = os.path.join(tempdir, "simple-alpha.png")
|
||||||
|
shutil.copy(sample_file, dest_file)
|
||||||
|
|
||||||
self.assertTrue(os.path.isfile(parser.archive_path))
|
parser.parse(dest_file, "image/png")
|
||||||
|
|
||||||
self.assertContainsStrings(parser.get_text(), ["This is a test document."])
|
self.assertTrue(os.path.isfile(parser.archive_path))
|
||||||
|
|
||||||
|
self.assertContainsStrings(parser.get_text(), ["This is a test document."])
|
||||||
|
|
||||||
def test_image_calc_a4_dpi(self):
|
def test_image_calc_a4_dpi(self):
|
||||||
parser = RasterisedDocumentParser(None)
|
parser = RasterisedDocumentParser(None)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user