mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
replace thumbnail creation with mock
This commit is contained in:
parent
5ef86f9489
commit
3c81a7468b
@ -57,24 +57,21 @@ class TestParser(TestCase):
|
|||||||
sha256.update(data)
|
sha256.update(data)
|
||||||
return sha256.hexdigest()
|
return sha256.hexdigest()
|
||||||
|
|
||||||
|
@mock.patch("paperless_mail.parsers.make_thumbnail_from_pdf")
|
||||||
@mock.patch("documents.loggers.LoggingMixin.log") # Disable log output
|
@mock.patch("documents.loggers.LoggingMixin.log") # Disable log output
|
||||||
def test_get_thumbnail(self, m):
|
def test_get_thumbnail(self, m, mock_make_thumbnail_from_pdf: mock.MagicMock):
|
||||||
parser = MailDocumentParser(None)
|
parser = MailDocumentParser(None)
|
||||||
thumb = parser.get_thumbnail(
|
thumb = parser.get_thumbnail(
|
||||||
os.path.join(self.SAMPLE_FILES, "simple_text.eml"),
|
os.path.join(self.SAMPLE_FILES, "simple_text.eml"),
|
||||||
"message/rfc822",
|
"message/rfc822",
|
||||||
)
|
)
|
||||||
self.assertTrue(os.path.isfile(thumb))
|
self.assertEqual(
|
||||||
thumb_hash = self.hashfile(thumb)
|
parser.archive_path,
|
||||||
|
mock_make_thumbnail_from_pdf.call_args_list[0].args[0],
|
||||||
# The created intermediary pdf is not reproducible. But the thumbnail image should always look the same.
|
|
||||||
expected_hash = (
|
|
||||||
"eeb2cf861f4873d2e569d0dfbfd385c2ac11722accf0fd3a32a54e3b115317a9"
|
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
thumb_hash,
|
parser.tempdir,
|
||||||
expected_hash,
|
mock_make_thumbnail_from_pdf.call_args_list[0].args[1],
|
||||||
"Thumbnail file hash not as expected.",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@mock.patch("documents.loggers.LoggingMixin.log")
|
@mock.patch("documents.loggers.LoggingMixin.log")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user