def test_extract_sender_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_sender(message)
def test_extract_sender(mime_header, compat32_header, expected_sender): mime_message = EmailMessage() mime_message["From"] = mime_header mime_sender = extract_sender(mime_message) assert mime_sender == expected_sender compat32_message = Message() compat32_message["From"] = compat32_header compat32_sender = extract_sender(compat32_message) assert compat32_sender == expected_sender
def test_extract_sender(): message = EmailMessage() message["From"] = Address(username="******", domain="example.com") sender = extract_sender(message) assert sender == message["From"]
def test_extract_sender_prefers_sender_header(): message = EmailMessage() message["From"] = Address(username="******", domain="example.com") message["Sender"] = Address(username="******", domain="example.com") sender = extract_sender(message) assert sender != message["From"] assert sender == message["Sender"]
def test_extract_sender_prefers_sender_header(): message = EmailMessage() message["From"] = "*****@*****.**" message["Sender"] = "*****@*****.**" sender = extract_sender(message) assert sender != message["From"] assert sender == message["Sender"]
def test_extract_sender_resent_message(): message = EmailMessage() message["From"] = Address(username="******", domain="example.com") message["Resent-Date"] = "Mon, 20 Nov 2017 21:04:27 -0000" message["Resent-From"] = Address(username="******", domain="example.com") sender = extract_sender(message) assert sender == message["Resent-From"] assert sender != message["From"]
def test_extract_sender_resent_message(): message = EmailMessage() message["From"] = "*****@*****.**" message["Resent-Date"] = "Mon, 20 Nov 2017 21:04:27 -0000" message["Resent-From"] = "*****@*****.**" sender = extract_sender(message) assert sender == message["Resent-From"] assert sender != message["From"]