def test_extract_recipients_valueerror_on_multiple_resent_message(): message = EmailMessage() message["Resent-Date"] = "Mon, 20 Nov 2016 21:04:27 -0000" message["Resent-Date"] = "Mon, 20 Nov 2017 21:04:27 -0000" with pytest.raises(ValueError): extract_recipients(message)
def test_extract_recipients_with_iterable_of_strings(): message = EmailMessage() message["To"] = ("*****@*****.**", "you") recipients = extract_recipients(message) assert recipients == ["*****@*****.**", "you"]
def test_extract_recipients_includes_bcc(): message = EmailMessage() message["Bcc"] = Address(username="******", domain="example.com") recipients = extract_recipients(message) assert recipients == [message["Bcc"]]
def test_extract_recipients_invalid_email(): message = EmailMessage() message["Cc"] = "me" recipients = extract_recipients(message) assert recipients == ["me"]
def test_extract_recipients_includes_bcc(): message = EmailMessage() message["Bcc"] = "*****@*****.**" recipients = extract_recipients(message) assert recipients == [message["Bcc"]]
def test_extract_recipients(): message = EmailMessage() message["To"] = Address(username="******", domain="example.com") message["Cc"] = Address(username="******", domain="example.com") recipients = extract_recipients(message) assert recipients == [message["To"], message["Cc"]]
def test_extract_recipients( mime_to_header, mime_cc_header, compat32_to_header, compat32_cc_header, expected_recipients, ): mime_message = EmailMessage() mime_message["To"] = mime_to_header mime_message["Cc"] = mime_cc_header mime_recipients = extract_recipients(mime_message) assert mime_recipients == expected_recipients compat32_message = Message() compat32_message["To"] = compat32_to_header compat32_message["Cc"] = compat32_cc_header compat32_recipients = extract_recipients(compat32_message) assert compat32_recipients == expected_recipients
def test_extract_recipients_resent_message(): message = EmailMessage() message["To"] = Address(username="******", domain="example.com") message["Cc"] = Address(username="******", domain="example.com") message["Bcc"] = Address(username="******", domain="example.com") message["Resent-Date"] = "Mon, 20 Nov 2017 21:04:27 -0000" message["Resent-To"] = Address(username="******", domain="example.com") message["Resent-Cc"] = Address(username="******", domain="example.com") message["Resent-Bcc"] = Address(username="******", domain="example.com") recipients = extract_recipients(message) assert message["Resent-To"] in recipients assert message["Resent-Cc"] in recipients assert message["Resent-Bcc"] in recipients assert message["To"] not in recipients assert message["Cc"] not in recipients assert message["Bcc"] not in recipients
def test_extract_recipients_resent_message(): message = EmailMessage() message["To"] = "*****@*****.**" message["Cc"] = "*****@*****.**" message["Bcc"] = "*****@*****.**" message["Resent-Date"] = "Mon, 20 Nov 2017 21:04:27 -0000" message["Resent-To"] = "*****@*****.**" message["Resent-Cc"] = "*****@*****.**" message["Resent-Bcc"] = "*****@*****.**" recipients = extract_recipients(message) assert message["Resent-To"] in recipients assert message["Resent-Cc"] in recipients assert message["Resent-Bcc"] in recipients assert message["To"] not in recipients assert message["Cc"] not in recipients assert message["Bcc"] not in recipients