Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions froide/foirequest/tests/test_mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,11 @@ def test_html_only_mail(self):
self.assertIn(" ( https://", mail.body)
self.assertIn("*peter.mueller@kreis-steinfurt.de*", mail.body)

def test_invalid_mail_address(self):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally this should be more a unit test (and less like a integration test): parsing a whole email just to test parsing of addresses makes this test not very specific. Also adding a large email with an image attachment (?!) is too much.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the feedback! I agree this is to unspecific. I will remove this test and do it more like this (without parsing a whole email):

Suggested change
def test_invalid_mail_address(self):
def test_invalid_mail_address(self):
values = ["To: 'John Doe [#123]' <john.doe@example.com>"]
ret = get_address_list(values)
self.assertEqual('john.doe@example.com', ret[0].email)

with open(p("test_mail_14.txt"), "rb") as f:
mail = parse_email(f)
self.assertEqual('john.doe@example.com', mail.to[0][1])


class DeferredMessageTest(TestCase):
def setUp(self):
Expand Down
Loading