Skip to content

Commit f75e25d

Browse files
committed
fixes attachment test
1 parent e0b8f02 commit f75e25d

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

services/payments/src/simcore_service_payments/services/notifier_email.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ async def _create_user_email(
224224
# Invoice attachment (It is important that attachment is added after body)
225225
pdf_response = await _get_invoice_pdf(payment.invoice_pdf_url)
226226

227+
# file
227228
file_name = _extract_file_name(pdf_response)
228229
main_type, sub_type = _guess_file_type(file_name)
229230

services/payments/tests/unit/test_services_notifier_email.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
from simcore_service_payments.services.notifier_email import (
2525
_PRODUCT_NOTIFICATIONS_TEMPLATES,
2626
EmailProvider,
27-
_add_attachments,
2827
_create_email_session,
2928
_create_user_email,
29+
_guess_file_type,
3030
_PaymentData,
3131
_ProductData,
3232
_UserData,
@@ -128,9 +128,16 @@ async def test_send_email_workflow(
128128

129129
msg = await _create_user_email(env, user_data, payment_data, product_data)
130130

131-
attachment = tmp_path / "test-attachment.txt"
131+
attachment = tmp_path / "test-attachment.pdf"
132132
attachment.write_text(faker.text())
133-
_add_attachments(msg, [attachment])
133+
134+
main_type, sub_type = _guess_file_type(attachment.name)
135+
msg.add_attachment(
136+
attachment.read_bytes(),
137+
filename=attachment.name,
138+
maintype=main_type,
139+
subtype=sub_type,
140+
)
134141

135142
async with _create_email_session(settings) as smtp:
136143
await smtp.send_message(msg)

0 commit comments

Comments
 (0)