Skip to content

Commit

Permalink
Extra unit-test
Browse files Browse the repository at this point in the history
  • Loading branch information
seijihg committed Feb 6, 2024
1 parent 1a610ba commit 6d265e2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions mail/tests/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ def test_locking_prevents_multiple_executions(self, mock_cache, mock_smtp_send):
self.assertEqual(mock_cache.add.call_count, 2)
mock_cache.delete.assert_called_once_with("global_send_email_lock")

@mock.patch("mail.tasks.smtp_send")
def test_send_email_task_insufficient_parameters(self, mock_smtp_send):
mock_smtp_send.side_effect = lambda *args, **kwargs: None

with self.assertRaises(ValueError) as context:
send_email_task.apply(kwargs={}).get()

self.assertTrue("Insufficient parameters to build email." in str(context.exception))
mock_smtp_send.assert_not_called()


class NotifyUsersOfRejectedMailTests(TestCase):
@override_settings(EMAIL_USER="[email protected]", NOTIFY_USERS=["[email protected]"]) # /PS-IGNORE
Expand Down

0 comments on commit 6d265e2

Please sign in to comment.