-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
MPP-3948: `complaintFeedbackType` is not required
- Loading branch information
Showing
2 changed files
with
11 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1495,23 +1495,23 @@ def test_minimal_complaint(self): | |
message = { | ||
"complaint": { | ||
"complainedRecipients": [{"emailAddress": "[email protected]"}], | ||
"complaintFeedbackType": "abuse", | ||
}, | ||
"mail": {"commonHeaders": {"from": ["[email protected]"]}}, | ||
} | ||
complaint_data = _get_complaint_data(message) | ||
with self.assertNoLogs(ERROR_LOG): | ||
complaint_data = _get_complaint_data(message) | ||
assert complaint_data == RawComplaintData( | ||
complained_recipients=[("[email protected]", {})], | ||
from_addresses=["[email protected]"], | ||
subtype="", | ||
user_agent="", | ||
feedback_type="abuse", | ||
feedback_type="", | ||
) | ||
|
||
def test_no_complained_recipients_error_logged(self): | ||
"""When complaint.complainedRecipients is missing, an error is logged.""" | ||
message = { | ||
"complaint": {"complaintFeedbackType": "abuse"}, | ||
"complaint": {}, | ||
"mail": {"commonHeaders": {"from": ["[email protected]"]}}, | ||
} | ||
with self.assertLogs(ERROR_LOG) as error_logs: | ||
|
@@ -1521,12 +1521,12 @@ def test_no_complained_recipients_error_logged(self): | |
(err_log,) = error_logs.records | ||
assert err_log.msg == "_get_complaint_data: Unexpected message format" | ||
assert getattr(err_log, "missing_key") == "complainedRecipients" | ||
assert getattr(err_log, "found_keys") == "complaintFeedbackType" | ||
assert getattr(err_log, "found_keys") == "" | ||
|
||
def test_empty_complained_recipients_error_logged(self): | ||
"""When complaint.complainedRecipients is empty, an error is logged.""" | ||
message = { | ||
"complaint": {"complainedRecipients": [], "complaintFeedbackType": "abuse"}, | ||
"complaint": {"complainedRecipients": []}, | ||
"mail": {"commonHeaders": {"from": ["[email protected]"]}}, | ||
} | ||
with self.assertLogs(ERROR_LOG) as error_logs: | ||
|
@@ -1544,7 +1544,6 @@ def test_wrong_complained_recipients_error_logged(self): | |
message = { | ||
"complaint": { | ||
"complainedRecipients": [{"foo": "bar"}], | ||
"complaintFeedbackType": "abuse", | ||
}, | ||
"mail": {"commonHeaders": {"from": ["[email protected]"]}}, | ||
} | ||
|
@@ -1562,7 +1561,6 @@ def test_no_mail_error_logged(self): | |
message = { | ||
"complaint": { | ||
"complainedRecipients": [{"emailAddress": "[email protected]"}], | ||
"complaintFeedbackType": "abuse", | ||
}, | ||
} | ||
with self.assertLogs(ERROR_LOG) as error_logs: | ||
|
@@ -1579,7 +1577,6 @@ def test_no_common_headers_error_logged(self): | |
message = { | ||
"complaint": { | ||
"complainedRecipients": [{"emailAddress": "[email protected]"}], | ||
"complaintFeedbackType": "abuse", | ||
}, | ||
"mail": {}, | ||
} | ||
|
@@ -1597,7 +1594,6 @@ def test_no_from_header_error_logged(self): | |
message = { | ||
"complaint": { | ||
"complainedRecipients": [{"emailAddress": "[email protected]"}], | ||
"complaintFeedbackType": "abuse", | ||
}, | ||
"mail": {"commonHeaders": {}}, | ||
} | ||
|
@@ -1610,23 +1606,18 @@ def test_no_from_header_error_logged(self): | |
assert getattr(err_log, "missing_key") == "from" | ||
assert getattr(err_log, "found_keys") == "" | ||
|
||
def test_no_feedback_type_error_logged(self): | ||
"""If the From header entry is missing, an error is logged.""" | ||
def test_no_feedback_type_not_an_error(self): | ||
"""If the feedback type is missing, no error is logged""" | ||
message = { | ||
"complaint": { | ||
"complainedRecipients": [{"emailAddress": "[email protected]"}], | ||
}, | ||
"mail": {"commonHeaders": {"from": ["[email protected]"]}}, | ||
} | ||
with self.assertLogs(ERROR_LOG) as error_logs: | ||
with self.assertNoLogs(ERROR_LOG): | ||
complaint_data = _get_complaint_data(message) | ||
assert complaint_data.feedback_type == "" | ||
|
||
(err_log,) = error_logs.records | ||
assert err_log.msg == "_get_complaint_data: Unexpected message format" | ||
assert getattr(err_log, "missing_key") == "complaintFeedbackType" | ||
assert getattr(err_log, "found_keys") == "complainedRecipients" | ||
|
||
|
||
class GatherComplainersTest(TestCase): | ||
""" | ||
|
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