mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
Save MailRule and MailAccount objects in tests
This fixes the errors in the tests that the new many-to-many assign_tags property cannot be accessed due to MailRule not having an id. In one case it it necessary to give additional names to both objects as several are created.
This commit is contained in:
parent
4022284059
commit
37f7ef41f2
@ -308,10 +308,12 @@ class TestMail(DirectoriesMixin, TestCase):
|
||||
)
|
||||
|
||||
account = MailAccount()
|
||||
account.save()
|
||||
rule = MailRule(
|
||||
assign_title_from=MailRule.TitleSource.FROM_FILENAME,
|
||||
account=account,
|
||||
)
|
||||
rule.save()
|
||||
|
||||
result = self.mail_account_handler.handle_message(message, rule)
|
||||
|
||||
@ -355,10 +357,12 @@ class TestMail(DirectoriesMixin, TestCase):
|
||||
)
|
||||
|
||||
account = MailAccount()
|
||||
account.save()
|
||||
rule = MailRule(
|
||||
assign_title_from=MailRule.TitleSource.FROM_FILENAME,
|
||||
account=account,
|
||||
)
|
||||
rule.save()
|
||||
|
||||
result = self.mail_account_handler.handle_message(message, rule)
|
||||
|
||||
@ -381,10 +385,12 @@ class TestMail(DirectoriesMixin, TestCase):
|
||||
)
|
||||
|
||||
account = MailAccount()
|
||||
account.save()
|
||||
rule = MailRule(
|
||||
assign_title_from=MailRule.TitleSource.FROM_FILENAME,
|
||||
account=account,
|
||||
)
|
||||
rule.save()
|
||||
|
||||
result = self.mail_account_handler.handle_message(message, rule)
|
||||
|
||||
@ -406,11 +412,13 @@ class TestMail(DirectoriesMixin, TestCase):
|
||||
)
|
||||
|
||||
account = MailAccount()
|
||||
account.save()
|
||||
rule = MailRule(
|
||||
assign_title_from=MailRule.TitleSource.FROM_FILENAME,
|
||||
account=account,
|
||||
attachment_type=MailRule.AttachmentProcessing.EVERYTHING,
|
||||
)
|
||||
rule.save()
|
||||
|
||||
result = self.mail_account_handler.handle_message(message, rule)
|
||||
|
||||
@ -440,12 +448,15 @@ class TestMail(DirectoriesMixin, TestCase):
|
||||
for (pattern, matches) in tests:
|
||||
matches.sort()
|
||||
self.async_task.reset_mock()
|
||||
account = MailAccount()
|
||||
account = MailAccount(name=str(uuid.uuid4()))
|
||||
account.save()
|
||||
rule = MailRule(
|
||||
name=str(uuid.uuid4()),
|
||||
assign_title_from=MailRule.TitleSource.FROM_FILENAME,
|
||||
account=account,
|
||||
filter_attachment_filename=pattern,
|
||||
)
|
||||
rule.save()
|
||||
|
||||
result = self.mail_account_handler.handle_message(message, rule)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user