From e1e11de2b546f87a6ed035feed07f868b29abcb7 Mon Sep 17 00:00:00 2001 From: jonaswinkler Date: Mon, 18 Jan 2021 22:23:53 +0100 Subject: [PATCH] mail tests --- src/paperless_mail/tests/test_mail.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/paperless_mail/tests/test_mail.py b/src/paperless_mail/tests/test_mail.py index 0104f5023..bec0ff4b4 100644 --- a/src/paperless_mail/tests/test_mail.py +++ b/src/paperless_mail/tests/test_mail.py @@ -1,3 +1,4 @@ +import os import uuid from collections import namedtuple from typing import ContextManager @@ -9,6 +10,7 @@ from django.test import TestCase from imap_tools import MailMessageFlags, MailboxFolderSelectError from documents.models import Correspondent +from documents.tests.utils import DirectoriesMixin from paperless_mail import tasks from paperless_mail.mail import MailError, MailAccountHandler from paperless_mail.models import MailRule, MailAccount @@ -130,7 +132,7 @@ def fake_magic_from_buffer(buffer, mime=False): @mock.patch('paperless_mail.mail.magic.from_buffer', fake_magic_from_buffer) -class TestMail(TestCase): +class TestMail(DirectoriesMixin, TestCase): def setUp(self): patcher = mock.patch('paperless_mail.mail.MailBox') @@ -146,6 +148,7 @@ class TestMail(TestCase): self.reset_bogus_mailbox() self.mail_account_handler = MailAccountHandler() + super(TestMail, self).setUp() def reset_bogus_mailbox(self): self.bogus_mailbox.messages = [] @@ -220,9 +223,13 @@ class TestMail(TestCase): args1, kwargs1 = self.async_task.call_args_list[0] args2, kwargs2 = self.async_task.call_args_list[1] + self.assertTrue(os.path.isfile(kwargs1['path']), kwargs1['path']) + self.assertEqual(kwargs1['override_title'], "file_0") self.assertEqual(kwargs1['override_filename'], "file_0.pdf") + self.assertTrue(os.path.isfile(kwargs2['path']), kwargs1['path']) + self.assertEqual(kwargs2['override_title'], "file_1") self.assertEqual(kwargs2['override_filename'], "file_1.pdf") @@ -253,6 +260,7 @@ class TestMail(TestCase): self.assertEqual(self.async_task.call_count, 1) args, kwargs = self.async_task.call_args + self.assertTrue(os.path.isfile(kwargs['path']), kwargs['path']) self.assertEqual(kwargs['override_filename'], "f1.pdf") def test_handle_disposition(self):