Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

Commit

Permalink
fixed a test case
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Winkler committed Nov 18, 2020
1 parent b89e836 commit 07e2ff0
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/paperless_mail/tests/test_mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ def test_get_correspondent(self):
me_localhost = Correspondent.objects.create(name=message2.from_)
someone_else = Correspondent.objects.create(name="someone else")

rule = MailRule(assign_correspondent_from=MailRule.CORRESPONDENT_FROM_NOTHING)
rule = MailRule(name="a", assign_correspondent_from=MailRule.CORRESPONDENT_FROM_NOTHING)
self.assertIsNone(get_correspondent(message, rule))

rule = MailRule(assign_correspondent_from=MailRule.CORRESPONDENT_FROM_EMAIL)
rule = MailRule(name="b", assign_correspondent_from=MailRule.CORRESPONDENT_FROM_EMAIL)
c = get_correspondent(message, rule)
self.assertIsNotNone(c)
self.assertEqual(c.name, "someone@somewhere.com")
Expand All @@ -159,15 +159,15 @@ def test_get_correspondent(self):
self.assertEqual(c.name, "me@localhost.com")
self.assertEqual(c.id, me_localhost.id)

rule = MailRule(assign_correspondent_from=MailRule.CORRESPONDENT_FROM_NAME)
rule = MailRule(name="c", assign_correspondent_from=MailRule.CORRESPONDENT_FROM_NAME)
c = get_correspondent(message, rule)
self.assertIsNotNone(c)
self.assertEqual(c.name, "Someone!")
c = get_correspondent(message2, rule)
self.assertIsNotNone(c)
self.assertEqual(c.id, me_localhost.id)

rule = MailRule(assign_correspondent_from=MailRule.CORRESPONDENT_FROM_CUSTOM, assign_correspondent=someone_else)
rule = MailRule(name="d", assign_correspondent_from=MailRule.CORRESPONDENT_FROM_CUSTOM, assign_correspondent=someone_else)
c = get_correspondent(message, rule)
self.assertEqual(c, someone_else)

Expand All @@ -176,9 +176,9 @@ def test_get_title(self):
message.subject = "the message title"
att = namedtuple('Attachment', [])
att.filename = "this_is_the_file.pdf"
rule = MailRule(assign_title_from=MailRule.TITLE_FROM_FILENAME)
rule = MailRule(name="a", assign_title_from=MailRule.TITLE_FROM_FILENAME)
self.assertEqual(get_title(message, att, rule), "this_is_the_file")
rule = MailRule(assign_title_from=MailRule.TITLE_FROM_SUBJECT)
rule = MailRule(name="b", assign_title_from=MailRule.TITLE_FROM_SUBJECT)
self.assertEqual(get_title(message, att, rule), "the message title")

def test_handle_message(self):
Expand Down Expand Up @@ -307,7 +307,7 @@ def test_errors(self):

account = MailAccount.objects.create(name="test3", imap_server="", username="admin", password="secret")

rule = MailRule.objects.create(name="testrule", account=account, action=MailRule.ACTION_MOVE, action_parameter="doesnotexist", filter_subject="Claim")
rule = MailRule.objects.create(name="testrule2", account=account, action=MailRule.ACTION_MOVE, action_parameter="doesnotexist", filter_subject="Claim")

try:
self.mail_account_handler.handle_mail_account(account)
Expand All @@ -319,7 +319,7 @@ def test_errors(self):
def test_filters(self):

account = MailAccount.objects.create(name="test3", imap_server="", username="admin", password="secret")
rule = MailRule.objects.create(name="testrule", account=account, action=MailRule.ACTION_DELETE, filter_subject="Claim")
rule = MailRule.objects.create(name="testrule3", account=account, action=MailRule.ACTION_DELETE, filter_subject="Claim")

self.assertEqual(self.async_task.call_count, 0)

Expand Down

0 comments on commit 07e2ff0

Please sign in to comment.