generated from cfpb/open-source-project-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
35 additions
and
29 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
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
from fastapi import FastAPI | ||
from fastapi.testclient import TestClient | ||
from pytest_mock import MockerFixture | ||
from unittest.mock import Mock, patch | ||
from unittest.mock import Mock | ||
|
||
from regtech_api_commons.models.auth import AuthenticatedUser | ||
from starlette.authentication import AuthCredentials | ||
|
@@ -119,6 +119,10 @@ def test_email_dates( | |
self, mocker: MockerFixture, app_fixture: FastAPI, full_user_mock: Mock | ||
): | ||
client = TestClient(app_fixture) | ||
|
||
mock_settings = mocker.patch("regtech_mail_api.internal.settings") | ||
mock_settings.from_addr = "[email protected]" | ||
mock_settings.beta_body_template = "\nCongratulations! This email confirms that Test User submitted a filing on {formatted_date} was successful. The confirmation number for this filing is {confirmation_id}.{line_break}The beta platform is for testing purposes only and user-supplied data may be removed at any time. Email our support staff at [email protected] to share feedback or upload a new file to continue testing.\n" | ||
res = client.post( | ||
"/internal/confirmation/send", | ||
data=json.dumps( | ||
|
@@ -179,6 +183,11 @@ def test_confirmation_send( | |
self, mocker: MockerFixture, app_fixture: FastAPI, full_user_mock: Mock | ||
): | ||
client = TestClient(app_fixture) | ||
|
||
mock_settings = mocker.patch("regtech_mail_api.internal.settings") | ||
mock_settings.from_addr = "[email protected]" | ||
mock_settings.beta_body_template = "\nCongratulations! This email confirms that Test User submitted a filing on {formatted_date} was successful. The confirmation number for this filing is {confirmation_id}.{line_break}The beta platform is for testing purposes only and user-supplied data may be removed at any time. Email our support staff at [email protected] to share feedback or upload a new file to continue testing.\n" | ||
|
||
res = client.post( | ||
"/internal/confirmation/send", | ||
data=json.dumps( | ||
|
@@ -204,32 +213,29 @@ def test_confirmation_send( | |
assert res.status_code == 200 | ||
assert res.json()["email"] == expected_email | ||
|
||
mock_settings = mocker.MagicMock() | ||
mock_settings.environment = "PROD" | ||
mock_settings.prod_body_template = "\nCongratulations! This email confirms that Test User submitted a filing on {formatted_date} was successful. The confirmation number for this filing is test.{line_break}If you have any questions or need additional support, email our support staff at [email protected].\n" | ||
expected_email = { | ||
"subject": "Small Business Lending Data Filing Confirmation", | ||
"body": "\nCongratulations! This email confirms that Test User submitted a filing on Nov. 20, 2024 at 1:51 p.m. EST was successful. The confirmation number for this filing is test.\n\nIf you have any questions or need additional support, email our support staff at [email protected].\n", | ||
"from_addr": "[email protected]", | ||
"to": ["[email protected]", "[email protected]"], | ||
"cc": None, | ||
"bcc": None, | ||
} | ||
|
||
with patch("regtech_mail_api.internal.settings") as mock_settings: | ||
mock_settings.environment = "PROD" | ||
mock_settings.from_addr = "[email protected]" | ||
expected_email = { | ||
"subject": "Small Business Lending Data Filing Confirmation", | ||
"body": "\nCongratulations! This email confirms that Test User submitted a filing on Nov. 20, 2024 at 1:51 p.m. EST was successful. The confirmation number for this filing is test.\n\nIf you have any questions or need additional support, email our support staff at [email protected].\n", | ||
"from_addr": "[email protected]", | ||
"to": ["[email protected]", "[email protected]"], | ||
"cc": None, | ||
"bcc": None, | ||
} | ||
res = client.post( | ||
"/internal/confirmation/send", | ||
data=json.dumps( | ||
{ | ||
"confirmation_id": "test", | ||
"signer_email": "[email protected]", | ||
"signer_name": "Test User", | ||
"contact_email": "[email protected]", | ||
"timestamp": 1732128696, | ||
} | ||
), | ||
) | ||
|
||
res = client.post( | ||
"/internal/confirmation/send", | ||
data=json.dumps( | ||
{ | ||
"confirmation_id": "test", | ||
"signer_email": "[email protected]", | ||
"signer_name": "Test User", | ||
"contact_email": "[email protected]", | ||
"timestamp": 1732128696, | ||
} | ||
), | ||
) | ||
|
||
assert res.status_code == 200 | ||
assert res.json()["email"] == expected_email | ||
assert res.status_code == 200 | ||
assert res.json()["email"] == expected_email |