From: phail Date: Thu, 27 Oct 2022 21:41:29 +0000 (+0200) Subject: replace thumbnail creation with mock X-Git-Tag: v1.11.0~1^2~35^2~29 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3c81a7468b47cdf5a2df0826429df99ab21f769b;p=thirdparty%2Fpaperless-ngx.git replace thumbnail creation with mock --- diff --git a/src/paperless_mail/tests/test_parsers.py b/src/paperless_mail/tests/test_parsers.py index 953263f786..f4985a6ee3 100644 --- a/src/paperless_mail/tests/test_parsers.py +++ b/src/paperless_mail/tests/test_parsers.py @@ -57,24 +57,21 @@ class TestParser(TestCase): sha256.update(data) return sha256.hexdigest() + @mock.patch("paperless_mail.parsers.make_thumbnail_from_pdf") @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) thumb = parser.get_thumbnail( os.path.join(self.SAMPLE_FILES, "simple_text.eml"), "message/rfc822", ) - self.assertTrue(os.path.isfile(thumb)) - thumb_hash = self.hashfile(thumb) - - # The created intermediary pdf is not reproducible. But the thumbnail image should always look the same. - expected_hash = ( - "eeb2cf861f4873d2e569d0dfbfd385c2ac11722accf0fd3a32a54e3b115317a9" + self.assertEqual( + parser.archive_path, + mock_make_thumbnail_from_pdf.call_args_list[0].args[0], ) self.assertEqual( - thumb_hash, - expected_hash, - "Thumbnail file hash not as expected.", + parser.tempdir, + mock_make_thumbnail_from_pdf.call_args_list[0].args[1], ) @mock.patch("documents.loggers.LoggingMixin.log")