-
Notifications
You must be signed in to change notification settings - Fork 20
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 #2464 from cisagov/dk/2250-test-suite
Issue #2250: improvements to test suite
- Loading branch information
Showing
18 changed files
with
4,349 additions
and
3,703 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -6,8 +6,9 @@ | |
from waffle.testutils import override_flag | ||
from registrar.utility import email | ||
from registrar.utility.email import send_templated_email | ||
from .common import completed_domain_request, less_console_noise | ||
from .common import completed_domain_request | ||
|
||
from api.tests.common import less_console_noise_decorator | ||
from datetime import datetime | ||
import boto3_mocking # type: ignore | ||
|
||
|
@@ -19,6 +20,7 @@ def setUp(self): | |
|
||
@boto3_mocking.patching | ||
@override_flag("disable_email_sending", active=True) | ||
@less_console_noise_decorator | ||
def test_disable_email_flag(self): | ||
"""Test if the 'disable_email_sending' stops emails from being sent""" | ||
with boto3_mocking.clients.handler_for("sesv2", self.mock_client_class): | ||
|
@@ -36,13 +38,13 @@ def test_disable_email_flag(self): | |
self.assertFalse(self.mock_client.send_email.called) | ||
|
||
@boto3_mocking.patching | ||
@less_console_noise_decorator | ||
def test_submission_confirmation(self): | ||
"""Submission confirmation email works.""" | ||
domain_request = completed_domain_request() | ||
|
||
with boto3_mocking.clients.handler_for("sesv2", self.mock_client_class): | ||
with less_console_noise(): | ||
domain_request.submit() | ||
domain_request.submit() | ||
|
||
# check that an email was sent | ||
self.assertTrue(self.mock_client.send_email.called) | ||
|
@@ -74,25 +76,25 @@ def test_submission_confirmation(self): | |
self.assertIn("Anything else", body) | ||
|
||
@boto3_mocking.patching | ||
@less_console_noise_decorator | ||
def test_submission_confirmation_no_current_website_spacing(self): | ||
"""Test line spacing without current_website.""" | ||
domain_request = completed_domain_request(has_current_website=False) | ||
with boto3_mocking.clients.handler_for("sesv2", self.mock_client_class): | ||
with less_console_noise(): | ||
domain_request.submit() | ||
domain_request.submit() | ||
_, kwargs = self.mock_client.send_email.call_args | ||
body = kwargs["Content"]["Simple"]["Body"]["Text"]["Data"] | ||
self.assertNotIn("Current websites:", body) | ||
# spacing should be right between adjacent elements | ||
self.assertRegex(body, r"5555\n\n.gov domain:") | ||
|
||
@boto3_mocking.patching | ||
@less_console_noise_decorator | ||
def test_submission_confirmation_current_website_spacing(self): | ||
"""Test line spacing with current_website.""" | ||
domain_request = completed_domain_request(has_current_website=True) | ||
with boto3_mocking.clients.handler_for("sesv2", self.mock_client_class): | ||
with less_console_noise(): | ||
domain_request.submit() | ||
domain_request.submit() | ||
_, kwargs = self.mock_client.send_email.call_args | ||
body = kwargs["Content"]["Simple"]["Body"]["Text"]["Data"] | ||
self.assertIn("Current websites:", body) | ||
|
@@ -101,12 +103,12 @@ def test_submission_confirmation_current_website_spacing(self): | |
self.assertRegex(body, r"city.com\n\n.gov domain:") | ||
|
||
@boto3_mocking.patching | ||
@less_console_noise_decorator | ||
def test_submission_confirmation_other_contacts_spacing(self): | ||
"""Test line spacing with other contacts.""" | ||
domain_request = completed_domain_request(has_other_contacts=True) | ||
with boto3_mocking.clients.handler_for("sesv2", self.mock_client_class): | ||
with less_console_noise(): | ||
domain_request.submit() | ||
domain_request.submit() | ||
_, kwargs = self.mock_client.send_email.call_args | ||
body = kwargs["Content"]["Simple"]["Body"]["Text"]["Data"] | ||
self.assertIn("Other employees from your organization:", body) | ||
|
@@ -115,96 +117,97 @@ def test_submission_confirmation_other_contacts_spacing(self): | |
self.assertRegex(body, r"5557\n\nAnything else") | ||
|
||
@boto3_mocking.patching | ||
@less_console_noise_decorator | ||
def test_submission_confirmation_no_other_contacts_spacing(self): | ||
"""Test line spacing without other contacts.""" | ||
domain_request = completed_domain_request(has_other_contacts=False) | ||
with boto3_mocking.clients.handler_for("sesv2", self.mock_client_class): | ||
with less_console_noise(): | ||
domain_request.submit() | ||
domain_request.submit() | ||
_, kwargs = self.mock_client.send_email.call_args | ||
body = kwargs["Content"]["Simple"]["Body"]["Text"]["Data"] | ||
# spacing should be right between adjacent elements | ||
self.assertRegex(body, r"5556\n\nOther employees") | ||
self.assertRegex(body, r"None\n\nAnything else") | ||
|
||
@boto3_mocking.patching | ||
@less_console_noise_decorator | ||
def test_submission_confirmation_alternative_govdomain_spacing(self): | ||
"""Test line spacing with alternative .gov domain.""" | ||
domain_request = completed_domain_request(has_alternative_gov_domain=True) | ||
with boto3_mocking.clients.handler_for("sesv2", self.mock_client_class): | ||
with less_console_noise(): | ||
domain_request.submit() | ||
domain_request.submit() | ||
_, kwargs = self.mock_client.send_email.call_args | ||
body = kwargs["Content"]["Simple"]["Body"]["Text"]["Data"] | ||
self.assertIn("city1.gov", body) | ||
# spacing should be right between adjacent elements | ||
self.assertRegex(body, r"city.gov\n\nAlternative domains:\ncity1.gov\n\nPurpose of your domain:") | ||
|
||
@boto3_mocking.patching | ||
@less_console_noise_decorator | ||
def test_submission_confirmation_no_alternative_govdomain_spacing(self): | ||
"""Test line spacing without alternative .gov domain.""" | ||
domain_request = completed_domain_request(has_alternative_gov_domain=False) | ||
with boto3_mocking.clients.handler_for("sesv2", self.mock_client_class): | ||
with less_console_noise(): | ||
domain_request.submit() | ||
domain_request.submit() | ||
_, kwargs = self.mock_client.send_email.call_args | ||
body = kwargs["Content"]["Simple"]["Body"]["Text"]["Data"] | ||
self.assertNotIn("city1.gov", body) | ||
# spacing should be right between adjacent elements | ||
self.assertRegex(body, r"city.gov\n\nPurpose of your domain:") | ||
|
||
@boto3_mocking.patching | ||
@less_console_noise_decorator | ||
def test_submission_confirmation_about_your_organization_spacing(self): | ||
"""Test line spacing with about your organization.""" | ||
domain_request = completed_domain_request(has_about_your_organization=True) | ||
with boto3_mocking.clients.handler_for("sesv2", self.mock_client_class): | ||
with less_console_noise(): | ||
domain_request.submit() | ||
domain_request.submit() | ||
_, kwargs = self.mock_client.send_email.call_args | ||
body = kwargs["Content"]["Simple"]["Body"]["Text"]["Data"] | ||
self.assertIn("About your organization:", body) | ||
# spacing should be right between adjacent elements | ||
self.assertRegex(body, r"10002\n\nAbout your organization:") | ||
|
||
@boto3_mocking.patching | ||
@less_console_noise_decorator | ||
def test_submission_confirmation_no_about_your_organization_spacing(self): | ||
"""Test line spacing without about your organization.""" | ||
domain_request = completed_domain_request(has_about_your_organization=False) | ||
with boto3_mocking.clients.handler_for("sesv2", self.mock_client_class): | ||
with less_console_noise(): | ||
domain_request.submit() | ||
domain_request.submit() | ||
_, kwargs = self.mock_client.send_email.call_args | ||
body = kwargs["Content"]["Simple"]["Body"]["Text"]["Data"] | ||
self.assertNotIn("About your organization:", body) | ||
# spacing should be right between adjacent elements | ||
self.assertRegex(body, r"10002\n\nSenior official:") | ||
|
||
@boto3_mocking.patching | ||
@less_console_noise_decorator | ||
def test_submission_confirmation_anything_else_spacing(self): | ||
"""Test line spacing with anything else.""" | ||
domain_request = completed_domain_request(has_anything_else=True) | ||
with boto3_mocking.clients.handler_for("sesv2", self.mock_client_class): | ||
with less_console_noise(): | ||
domain_request.submit() | ||
domain_request.submit() | ||
_, kwargs = self.mock_client.send_email.call_args | ||
body = kwargs["Content"]["Simple"]["Body"]["Text"]["Data"] | ||
# spacing should be right between adjacent elements | ||
self.assertRegex(body, r"5557\n\nAnything else?") | ||
|
||
@boto3_mocking.patching | ||
@less_console_noise_decorator | ||
def test_submission_confirmation_no_anything_else_spacing(self): | ||
"""Test line spacing without anything else.""" | ||
domain_request = completed_domain_request(has_anything_else=False) | ||
with boto3_mocking.clients.handler_for("sesv2", self.mock_client_class): | ||
with less_console_noise(): | ||
domain_request.submit() | ||
domain_request.submit() | ||
_, kwargs = self.mock_client.send_email.call_args | ||
body = kwargs["Content"]["Simple"]["Body"]["Text"]["Data"] | ||
self.assertNotIn("Anything else", body) | ||
# spacing should be right between adjacent elements | ||
self.assertRegex(body, r"5557\n\n----") | ||
|
||
@boto3_mocking.patching | ||
@less_console_noise_decorator | ||
def test_send_email_with_attachment(self): | ||
with boto3_mocking.clients.handler_for("ses", self.mock_client_class): | ||
sender_email = "[email protected]" | ||
|
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
Oops, something went wrong.