mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-05 10:43:23 +02:00
Unit test
Adding stashed item
This commit is contained in:
parent
5c1e41bb55
commit
d36435a981
1 changed files with 21 additions and 1 deletions
|
@ -3,10 +3,12 @@
|
|||
from unittest.mock import MagicMock
|
||||
|
||||
from django.test import TestCase
|
||||
from waffle.testutils import override_switch
|
||||
from registrar.utility import email
|
||||
from registrar.utility.email import send_templated_email
|
||||
from .common import completed_domain_request, less_console_noise
|
||||
|
||||
from datetime import datetime
|
||||
from registrar.utility import email
|
||||
import boto3_mocking # type: ignore
|
||||
|
||||
|
||||
|
@ -15,6 +17,24 @@ class TestEmails(TestCase):
|
|||
self.mock_client_class = MagicMock()
|
||||
self.mock_client = self.mock_client_class.return_value
|
||||
|
||||
@boto3_mocking.patching
|
||||
@override_switch("disable_email_sending", active=True)
|
||||
def test_disable_email_switch(self):
|
||||
"""Test if the 'disable_email_sending' stops emails from being sent """
|
||||
with boto3_mocking.clients.handler_for("sesv2", self.mock_client_class):
|
||||
expected_message = "Email sending is disabled due to"
|
||||
with self.assertRaisesRegex(email.EmailSendingError, expected_message):
|
||||
send_templated_email(
|
||||
"test content",
|
||||
"test subject",
|
||||
"doesnotexist@igorville.com",
|
||||
context={"domain_request": self},
|
||||
bcc_address=None,
|
||||
)
|
||||
|
||||
# Assert that an email wasn't sent
|
||||
self.assertFalse(self.mock_client.send_email.called)
|
||||
|
||||
@boto3_mocking.patching
|
||||
def test_submission_confirmation(self):
|
||||
"""Submission confirmation email works."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue