Skip to content

Commit

Permalink
Changed path of source to regtech-mail-api/src/regtech_mail_api
Browse files Browse the repository at this point in the history
  • Loading branch information
jcadam14 committed Mar 18, 2024
1 parent 633c439 commit 5779ca2
Show file tree
Hide file tree
Showing 10 changed files with 440 additions and 294 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ COPY poetry.lock pyproject.toml log-config.yml ./
RUN poetry config virtualenvs.create false
RUN poetry install

COPY regtech_mail_api ./regtech_mail_api
COPY src/ ./

EXPOSE 8765

Expand Down
705 changes: 426 additions & 279 deletions poetry.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ description = ""
authors = ["CFPB's RegTech Team"]
readme = "README.md"
packages = [
{ include = "regtech_mail_api" }
{ include = "src/regtech_mail_api" }
]


[tool.poetry.dependencies]
python = "^3.12"
fastapi = {extras = ["all"], version = "^0.104.1"}
fastapi = {extras = ["all"], version = "^0.109.1"}
uvicorn = "^0.27.0.post1"
pyyaml = "^6.0.1"
email-validator = "^2.1.0.post1"
Expand All @@ -35,7 +35,7 @@ requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.pytest.ini_options]
pythonpath = ["regtech_mail_api"]
pythonpath = ["src"]
testpaths = ["tests"]
env = [
"KC_URL=http://localhost",
Expand Down
File renamed without changes.
9 changes: 4 additions & 5 deletions regtech_mail_api/api.py → src/regtech_mail_api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,17 @@ def read_root(request: Request):
@requires("authenticated")
async def send_email(request: Request):
sender_addr = request.user.email
sender_name = request.user.name
sender_name = request.user.name if request.user.name else ""
type = request.headers["case-type"]
subject = f"[DEV BETA] SBL User Request for {type}" + (
f" by {sender_name}" if sender_name else ""
)
subject = f"[DEV BETA] SBL User Request for {type}"

sender = f"{sender_name} <{sender_addr}>" if sender_name else sender_addr

form_data = await request.form()

body_lines = [f"{k}: {v}" for k, v in form_data.items()]
email_body = f"Contact Email: {sender_addr}\n\n"
email_body = f"Contact Email: {sender_addr}\n"
email_body += f"Contact Name: {sender_name}\n\n"
email_body += "\n".join(body_lines)

email = Email(subject, email_body, settings.from_addr, sender, to={settings.to})
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions tests/test_authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

@pytest.fixture
def app_fixture(mocker: MockerFixture) -> FastAPI:
from api import app
from regtech_mail_api.api import app

return app

Expand Down Expand Up @@ -74,7 +74,7 @@ def test_authed_endpoints(
}
}

mock = mocker.patch("api.send_email")
mock = mocker.patch("regtech_mail_api.api.send_email")
mock.return_value = {"email": email_json}
client = TestClient(app_fixture)
res = client.get("/")
Expand Down
8 changes: 4 additions & 4 deletions tests/test_send.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

@pytest.fixture
def app_fixture(mocker: MockerFixture) -> FastAPI:
from api import app
from regtech_mail_api.api import app

return app

Expand Down Expand Up @@ -58,7 +58,7 @@ def test_send_no_profile(
email_json = {
"email": {
"subject": "[DEV BETA] SBL User Request for Institution Profile Change",
"body": "Contact Email: [email protected]\n\nlei: 1234567890ABCDEFGHIJ\ninstitution_name_1: Fintech 1\ntin_1: 12-3456789\nrssd_1: 1234567",
"body": "Contact Email: [email protected]\nContact Name: \n\nlei: 1234567890ABCDEFGHIJ\ninstitution_name_1: Fintech 1\ntin_1: 12-3456789\nrssd_1: 1234567",
"from_addr": "[email protected]",
"sender": "[email protected]",
"to": ["[email protected]"],
Expand Down Expand Up @@ -88,8 +88,8 @@ def test_send(
):
email_json = {
"email": {
"subject": "[DEV BETA] SBL User Request for Institution Profile Change by Test User",
"body": "Contact Email: [email protected]\n\nlei: 1234567890ABCDEFGHIJ\ninstitution_name_1: Fintech 1\ntin_1: 12-3456789\nrssd_1: 1234567",
"subject": "[DEV BETA] SBL User Request for Institution Profile Change",
"body": "Contact Email: [email protected]\nContact Name: Test User\n\nlei: 1234567890ABCDEFGHIJ\ninstitution_name_1: Fintech 1\ntin_1: 12-3456789\nrssd_1: 1234567",
"from_addr": "[email protected]",
"sender": "Test User <[email protected]>",
"to": ["[email protected]"],
Expand Down

0 comments on commit 5779ca2

Please sign in to comment.