-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from Waghabond/master
Alter Email Message Default Policy to Comply With RFC 5322
- Loading branch information
Showing
6 changed files
with
24 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,10 +21,10 @@ def test_date(): | |
before = datetime.datetime.now(datetime.timezone.utc) | ||
msg = email.get_message(sender="[email protected]", subject="Some email") | ||
after = datetime.datetime.now(datetime.timezone.utc) | ||
date_strings = re.findall(r'(?<=Date: ).+', str(msg)) | ||
date_strings = re.findall(r'(?<=Date: )[^\r\n]+', str(msg)) | ||
assert len(date_strings) == 1 | ||
for dt_string in date_strings: | ||
|
||
# Validate the Date fits to the format | ||
datetime.datetime.strptime(dt_string, format) | ||
|
||
|
@@ -45,15 +45,15 @@ def test_message_id(): | |
msg = email.get_message(sender="[email protected]", subject="Some email") | ||
msg2 = email.get_message(sender="[email protected]", subject="Some email") | ||
|
||
message_ids = re.findall(r'(?<=Message-ID: ).+', str(msg)) | ||
message_ids = re.findall(r'(?<=Message-ID: )[^\r\n]+', str(msg)) | ||
assert len(message_ids) == 1 | ||
message_id = message_ids[0] | ||
|
||
# [0-9]{{12}}[.][0-9]{{5}}[.][0-9]{{20}} | ||
assert bool(re.search(fr'<[0-9.]+@{domain}>', message_id)) | ||
|
||
# Check another email has not the same Message-ID | ||
message_id_2 = re.findall(r'(?<=Message-ID: ).+', str(msg2))[0] | ||
message_id_2 = re.findall(r'(?<=Message-ID: )[^\r\n]+', str(msg2))[0] | ||
assert message_id != message_id_2 | ||
|
||
def test_cc_bcc(): | ||
|
@@ -73,7 +73,7 @@ def test_cc_bcc(): | |
Message-ID: <<message_id>> | ||
Date: <date> | ||
""")[1:] | ||
""")[1:].replace('\n', '\r\n') | ||
|
||
@pytest.mark.parametrize("how", ["instance", "email"]) | ||
def test_custom_headers(how): | ||
|
@@ -89,14 +89,14 @@ def test_custom_headers(how): | |
|
||
if how == "email": | ||
msg = email.get_message( | ||
sender="[email protected]", | ||
subject="Some email", | ||
sender="[email protected]", | ||
subject="Some email", | ||
headers=headers | ||
) | ||
elif how == "instance": | ||
email.headers = headers | ||
msg = email.get_message( | ||
sender="[email protected]", | ||
sender="[email protected]", | ||
subject="Some email", | ||
) | ||
msg = prune_generated_headers(str(msg)) | ||
|
@@ -107,7 +107,7 @@ def test_custom_headers(how): | |
Date: <date> | ||
Importance: high | ||
""")[1:] | ||
""")[1:].replace('\n', '\r\n') | ||
|
||
@pytest.mark.parametrize("how", ["instance", "email"]) | ||
def test_custom_headers_override(how): | ||
|
@@ -119,7 +119,7 @@ def test_custom_headers_override(how): | |
|
||
if how == "email": | ||
msg = email.get_message( | ||
sender="[email protected]", | ||
sender="[email protected]", | ||
subject="Some email", | ||
headers=headers | ||
) | ||
|
@@ -135,4 +135,4 @@ def test_custom_headers_override(how): | |
Message-ID: <167294165062.31860.1664530310632362057@LAPTOP-1234GML0> | ||
Date: Sun, 31 Jan 2021 06:56:46 +0000 | ||
""")[1:] | ||
""")[1:].replace('\n', '\r\n') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters