Skip to content
Merged
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
8 changes: 5 additions & 3 deletions ietf/ipr/management/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ def test_send_error_to_admin(self, process_mock, send_smtp_mock):
self.assertTrue(msg.is_multipart(), 'Error email should have attachments')
parts = msg.get_payload()
self.assertEqual(len(parts), 3, 'Error email should contain message, traceback, and original message')
content = parts[0].get_payload()
traceback = parts[1].get_payload()
original = parts[2].get_payload(decode=True).decode() # convert octet-stream to string
# decode=True decodes the quoted-printable encoding, including removing soft linebreaks.
# The .decode() converts the resulting octet-stream bytes to a string
content = parts[0].get_payload(decode=True).decode()
traceback = parts[1].get_payload(decode=True).decode()
original = parts[2].get_payload(decode=True).decode()
self.assertIn('RuntimeError', content, 'Error type should be included in error email')
self.assertIn('mock.py', content, 'File where error occurred should be included in error email')
self.assertIn('traceback', traceback.lower(), 'Traceback should be attached to error email')
Expand Down
7 changes: 5 additions & 2 deletions ietf/nomcom/management/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ def test_send_error_to_admins(self, send_smtp_mock):
self.assertEqual(msg['to'], 'admin@example.com', 'Email recipient should be the admins')
self.assertIn('error', msg['subject'], 'Email subject should indicate error')
self.assertFalse(msg.is_multipart(), 'Nomcom feedback error sent to admin should not have attachments')
content = msg.get_payload()
# decode=True decodes the quoted-printable encoding, including removing soft linebreaks.
# The .decode() converts the resulting octet-stream bytes to a string
content = msg.get_payload(decode=True).decode()
self.assertIn('CommandError', content, 'Admin email should contain error type')
self.assertIn('feedback_email.py', content, 'Admin email should contain file where error occurred')
self.assertNotIn('traceback', content.lower(), 'Admin email should not contain traceback')
Expand Down Expand Up @@ -63,7 +65,8 @@ def test_send_error_to_chair(self, create_feedback_mock, send_smtp_mock):
self.assertTrue(msg.is_multipart(), 'Chair feedback error should have attachments')
parts = msg.get_payload()
content = parts[0].get_payload()
# decode=True decodes the base64 encoding, .decode() converts the octet-stream bytes to a string
# decode=True decodes the quoted-printable encoding, including removing soft linebreaks.
# The .decode() converts the resulting octet-stream bytes to a string
attachment = parts[1].get_payload(decode=True).decode()
self.assertIn('RuntimeError', content, 'Nomcom email should contain error type')
self.assertIn('mock.py', content, 'Nomcom email should contain file where error occurred')
Expand Down