Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix for sending empty emails (#9317)
Maciej Korycinski3e8503d8a99c
diff --git a/saleor/plugins/admin_email/notify_events.py b/saleor/plugins/admin_email/notify_events.pyindex 1a2f21a734..88bedeaadd 100644--- a/saleor/plugins/admin_email/notify_events.py+++ b/saleor/plugins/admin_email/notify_events.py@@ -24,6 +24,9 @@ def send_set_staff_password_email(constants.SET_STAFF_PASSWORD_DEFAULT_TEMPLATE,constants.DEFAULT_EMAIL_TEMPLATES_PATH,)+ if not template:+ # Empty template means that we don't want to trigger a given event.+ returnsubject = get_email_subject(plugin.configuration,constants.SET_STAFF_PASSWORD_SUBJECT_FIELD,@@ -43,6 +46,9 @@ def send_csv_export_success(payload: dict, config: dict, plugin: "AdminEmailPlugconstants.CSV_EXPORT_SUCCESS_DEFAULT_TEMPLATE,constants.DEFAULT_EMAIL_TEMPLATES_PATH,)+ if not template:+ # Empty template means that we don't want to trigger a given event.+ returnsubject = get_email_subject(plugin.configuration,constants.CSV_EXPORT_SUCCESS_SUBJECT_FIELD,@@ -63,6 +69,9 @@ def send_staff_order_confirmation(constants.STAFF_ORDER_CONFIRMATION_DEFAULT_TEMPLATE,constants.DEFAULT_EMAIL_TEMPLATES_PATH,)+ if not template:+ # Empty template means that we don't want to trigger a given event.+ returnsubject = get_email_subject(plugin.configuration,constants.STAFF_ORDER_CONFIRMATION_SUBJECT_FIELD,@@ -82,6 +91,9 @@ def send_csv_export_failed(payload: dict, config: dict, plugin: "AdminEmailPlugiconstants.CSV_EXPORT_FAILED_TEMPLATE_DEFAULT_TEMPLATE,constants.DEFAULT_EMAIL_TEMPLATES_PATH,)+ if not template:+ # Empty template means that we don't want to trigger a given event.+ returnsubject = get_email_subject(plugin.configuration,constants.CSV_EXPORT_FAILED_SUBJECT_FIELD,@@ -101,6 +113,9 @@ def send_staff_reset_password(payload: dict, config: dict, plugin: "AdminEmailPlconstants.STAFF_PASSWORD_RESET_DEFAULT_TEMPLATE,constants.DEFAULT_EMAIL_TEMPLATES_PATH,)+ if not template:+ # Empty template means that we don't want to trigger a given event.+ returnsubject = get_email_subject(plugin.configuration,constants.STAFF_PASSWORD_RESET_SUBJECT_FIELD,diff --git a/saleor/plugins/admin_email/plugin.py b/saleor/plugins/admin_email/plugin.pyindex 4804c1464b..8ec53e11b1 100644--- a/saleor/plugins/admin_email/plugin.py+++ b/saleor/plugins/admin_email/plugin.py@@ -1,6 +1,6 @@import logging-from dataclasses import asdict, dataclass-from typing import List, Optional, Union+from dataclasses import asdict+from typing import List, Unionfrom django.conf import settingsfrom promise.promise import Promise@@ -31,27 +31,6 @@ from .notify_events import (logger = logging.getLogger(__name__)-@dataclass-class AdminTemplate:- staff_order_confirmation: Optional[str]- set_staff_password_email: Optional[str]- csv_export_success: Optional[str]- csv_export_failed: Optional[str]- staff_reset_password: Optional[str]---def get_admin_template_map(templates: AdminTemplate):- return {- AdminNotifyEvent.STAFF_ORDER_CONFIRMATION: templates.staff_order_confirmation,- AdminNotifyEvent.ACCOUNT_SET_STAFF_PASSWORD: templates.set_staff_password_email,- AdminNotifyEvent.CSV_EXPORT_SUCCESS: (templates.csv_export_success),- AdminNotifyEvent.CSV_EXPORT_FAILED: templates.csv_export_failed,- AdminNotifyEvent.ACCOUNT_STAFF_RESET_PASSWORD: (- templates.set_staff_password_email- ),- }--def get_admin_event_map():return {AdminNotifyEvent.STAFF_ORDER_CONFIRMATION: send_staff_order_confirmation,@@ -201,22 +180,6 @@ class AdminEmailPlugin(BasePlugin):use_ssl=configuration["use_ssl"] or settings.EMAIL_USE_SSL,)- self.templates = AdminTemplate(- csv_export_failed=configuration[constants.CSV_EXPORT_FAILED_TEMPLATE_FIELD],- csv_export_success=configuration[- constants.CSV_EXPORT_SUCCESS_TEMPLATE_FIELD- ],- set_staff_password_email=configuration[- constants.SET_STAFF_PASSWORD_TEMPLATE_FIELD- ],- staff_order_confirmation=configuration[- constants.STAFF_ORDER_CONFIRMATION_TEMPLATE_FIELD- ],- staff_reset_password=configuration[- constants.STAFF_PASSWORD_RESET_TEMPLATE_FIELD- ],- )-def resolve_plugin_configuration(self, request) -> Union[PluginConfigurationType, Promise[PluginConfigurationType]]:@@ -263,10 +226,6 @@ class AdminEmailPlugin(BasePlugin):logger.warning("Missing handler for event %s", event)return previous_value- template_map = get_admin_template_map(self.templates)- if not template_map.get(event):- return previous_value-event_func = event_map[event]config = asdict(self.config) # type: ignoreevent_func(payload, config, self)diff --git a/saleor/plugins/admin_email/tests/test_notify_events.py b/saleor/plugins/admin_email/tests/test_notify_events.pyindex 4fbf302d52..c10a5e2566 100644--- a/saleor/plugins/admin_email/tests/test_notify_events.py+++ b/saleor/plugins/admin_email/tests/test_notify_events.py@@ -36,6 +36,31 @@ def test_send_account_password_reset_event()+ "saleor.plugins.admin_email.notify_events.send_staff_password_reset_email_task."+ "delay"+)+def test_send_account_password_reset_event_empty_template(+ mocked_email_task, customer_user, admin_email_plugin+):+ token = "token123"+ payload = {+ "user": get_default_user_payload(customer_user),+ "recipient_email": "[email protected]",+ "token": token,+ "reset_url": f"http://localhost:8000/redirect{token}",+ "domain": "localhost:8000",+ "site_name": "Saleor",+ }+ config = {"host": "localhost", "port": "1025"}+ send_staff_reset_password(+ payload=payload,+ config=config,+ plugin=admin_email_plugin(staff_password_reset_template=""),+ )+ assert not mocked_email_task.called++@mock.patch("saleor.plugins.admin_email.notify_events.send_set_staff_password_email_task.delay")@@ -54,6 +79,26 @@ def test_send_set_staff_password_email(mocked_email_task, admin_email_plugin):)+ "saleor.plugins.admin_email.notify_events.send_set_staff_password_email_task.delay"+)+def test_send_set_staff_password_email_empty_template(+ mocked_email_task, admin_email_plugin+):+ payload = {+ "recipient_email": "[email protected]",+ "redirect_url": "http://127.0.0.1:8000/redirect",+ "token": "token123",+ }+ config = {"host": "localhost", "port": "1025"}+ send_set_staff_password_email(+ payload=payload,+ config=config,+ plugin=admin_email_plugin(set_staff_password_template=""),+ )+ assert not mocked_email_task.called++@mock.patch("saleor.plugins.admin_email.notify_events.""send_email_with_link_to_download_file_task.delay"@@ -70,6 +115,24 @@ def test_send_csv_export_success(mocked_email_task, admin_email_plugin):)+ "saleor.plugins.admin_email.notify_events."+ "send_email_with_link_to_download_file_task.delay"+)+def test_send_csv_product_export_success_empty_template(+ mocked_email_task, admin_email_plugin+):+ payload = {+ "recipient_email": "[email protected]",+ "csv_link": "http://127.0.0.1:8000/download/csv",+ }+ config = {"host": "localhost", "port": "1025"}+ send_csv_export_success(+ payload=payload, config=config, plugin=admin_email_plugin(csv_product_export="")+ )+ assert not mocked_email_task.called++@mock.patch("saleor.plugins.admin_email.notify_events.""send_staff_order_confirmation_email_task.delay"@@ -89,6 +152,27 @@ def test_send_staff_order_confirmation(mocked_email_task, order, admin_email_plu)+ "saleor.plugins.admin_email.notify_events."+ "send_staff_order_confirmation_email_task.delay"+)+def test_send_staff_order_confirmation_empty_template(+ mocked_email_task, order, admin_email_plugin+):+ order_payload = get_default_order_payload(order)+ payload = {+ "order": order_payload,+ "recipient_list": ["[email protected]"],+ }+ config = {"host": "localhost", "port": "1025"}+ send_staff_order_confirmation(+ payload=payload,+ config=config,+ plugin=admin_email_plugin(staff_order_confirmation=""),+ )+ assert not mocked_email_task.called++@mock.patch("saleor.plugins.admin_email.notify_events." "send_export_failed_email_task.delay")@@ -101,3 +185,19 @@ def test_send_csv_export_failed(mocked_email_task, admin_email_plugin):mocked_email_task.assert_called_with(payload["recipient_email"], payload, config, mock.ANY, mock.ANY)+++ "saleor.plugins.admin_email.notify_events." "send_export_failed_email_task.delay"+)+def test_send_csv_export_failed_empty_template(mocked_email_task, admin_email_plugin):+ payload = {+ "recipient_email": "[email protected]",+ }+ config = {"host": "localhost", "port": "1025"}+ send_csv_export_failed(+ payload=payload,+ config=config,+ plugin=admin_email_plugin(csv_product_export_failed=""),+ )+ assert not mocked_email_task.calleddiff --git a/saleor/plugins/user_email/notify_events.py b/saleor/plugins/user_email/notify_events.pyindex 686162dbd6..2b228593a6 100644--- a/saleor/plugins/user_email/notify_events.py+++ b/saleor/plugins/user_email/notify_events.py@@ -34,6 +34,9 @@ def send_account_password_reset_event(constants.ACCOUNT_PASSWORD_RESET_DEFAULT_TEMPLATE,constants.DEFAULT_EMAIL_TEMPLATES_PATH,)+ if not template:+ # Empty template means that we don't want to trigger a given event.+ returnsubject = get_email_subject(plugin.configuration,constants.ACCOUNT_PASSWORD_RESET_SUBJECT_FIELD,@@ -56,6 +59,9 @@ def send_account_confirmation(payload: dict, config: dict, plugin: "UserEmailPluconstants.ACCOUNT_CONFIRMATION_DEFAULT_TEMPLATE,constants.DEFAULT_EMAIL_TEMPLATES_PATH,)+ if not template:+ # Empty template means that we don't want to trigger a given event.+ returnsubject = get_email_subject(plugin.configuration,constants.ACCOUNT_CONFIRMATION_SUBJECT_FIELD,@@ -76,6 +82,9 @@ def send_account_change_email_request(constants.ACCOUNT_CHANGE_EMAIL_REQUEST_DEFAULT_TEMPLATE,constants.DEFAULT_EMAIL_TEMPLATES_PATH,)+ if not template:+ # Empty template means that we don't want to trigger a given event.+ returnsubject = get_email_subject(plugin.configuration,constants.ACCOUNT_CHANGE_EMAIL_REQUEST_SUBJECT_FIELD,@@ -96,6 +105,9 @@ def send_account_change_email_confirm(constants.ACCOUNT_CHANGE_EMAIL_CONFIRM_DEFAULT_TEMPLATE,constants.DEFAULT_EMAIL_TEMPLATES_PATH,)+ if not template:+ # Empty template means that we don't want to trigger a given event.+ returnsubject = get_email_subject(plugin.configuration,constants.ACCOUNT_CHANGE_EMAIL_CONFIRM_SUBJECT_FIELD,@@ -114,6 +126,9 @@ def send_account_delete(payload: dict, config: dict, plugin: "UserEmailPlugin"):constants.ACCOUNT_DELETE_DEFAULT_TEMPLATE,constants.DEFAULT_EMAIL_TEMPLATES_PATH,)+ if not template:+ # Empty template means that we don't want to trigger a given event.+ returnsubject = get_email_subject(plugin.configuration,constants.ACCOUNT_DELETE_SUBJECT_FIELD,@@ -132,6 +147,9 @@ def send_gift_card(payload: dict, config: dict, plugin: "UserEmailPlugin"):constants.SEND_GIFT_CARD_DEFAULT_TEMPLATE,constants.DEFAULT_EMAIL_TEMPLATES_PATH,)+ if not template:+ # Empty template means that we don't want to trigger a given event.+ returnsubject = get_email_subject(plugin.configuration,@@ -151,6 +169,9 @@ def send_account_set_customer_password(constants.ACCOUNT_SET_CUSTOMER_PASSWORD_DEFAULT_TEMPLATE,constants.DEFAULT_EMAIL_TEMPLATES_PATH,)+ if not template:+ # Empty template means that we don't want to trigger a given event.+ returnsubject = get_email_subject(plugin.configuration,constants.ACCOUNT_SET_CUSTOMER_PASSWORD_SUBJECT_FIELD,@@ -169,6 +190,9 @@ def send_invoice(payload: dict, config: dict, plugin: "UserEmailPlugin"):constants.INVOICE_READY_DEFAULT_TEMPLATE,constants.DEFAULT_EMAIL_TEMPLATES_PATH,)+ if not template:+ # Empty template means that we don't want to trigger a given event.+ returnsubject = get_email_subject(plugin.configuration,constants.INVOICE_READY_SUBJECT_FIELD,@@ -185,6 +209,9 @@ def send_order_confirmation(payload: dict, config: dict, plugin: "UserEmailPlugiconstants.ORDER_CONFIRMATION_DEFAULT_TEMPLATE,constants.DEFAULT_EMAIL_TEMPLATES_PATH,)+ if not template:+ # Empty template means that we don't want to trigger a given event.+ returnsubject = get_email_subject(plugin.configuration,constants.ORDER_CONFIRMATION_SUBJECT_FIELD,@@ -205,6 +232,9 @@ def send_fulfillment_confirmation(constants.ORDER_FULFILLMENT_CONFIRMATION_DEFAULT_TEMPLATE,constants.DEFAULT_EMAIL_TEMPLATES_PATH,)+ if not template:+ # Empty template means that we don't want to trigger a given event.+ returnsubject = get_email_subject(plugin.configuration,constants.ORDER_FULFILLMENT_CONFIRMATION_SUBJECT_FIELD,@@ -223,6 +253,9 @@ def send_fulfillment_update(payload: dict, config: dict, plugin: "UserEmailPlugiconstants.ORDER_FULFILLMENT_UPDATE_DEFAULT_TEMPLATE,constants.DEFAULT_EMAIL_TEMPLATES_PATH,)+ if not template:+ # Empty template means that we don't want to trigger a given event.+ returnsubject = get_email_subject(plugin.configuration,constants.ORDER_FULFILLMENT_UPDATE_SUBJECT_FIELD,@@ -241,6 +274,9 @@ def send_payment_confirmation(payload: dict, config: dict, plugin: "UserEmailPluconstants.ORDER_PAYMENT_CONFIRMATION_DEFAULT_TEMPLATE,constants.DEFAULT_EMAIL_TEMPLATES_PATH,)+ if not template:+ # Empty template means that we don't want to trigger a given event.+ returnsubject = get_email_subject(plugin.configuration,constants.ORDER_PAYMENT_CONFIRMATION_SUBJECT_FIELD,@@ -259,6 +295,9 @@ def send_order_canceled(payload: dict, config: dict, plugin: "UserEmailPlugin"):constants.ORDER_CANCELED_DEFAULT_TEMPLATE,constants.DEFAULT_EMAIL_TEMPLATES_PATH,)+ if not template:+ # Empty template means that we don't want to trigger a given event.+ returnsubject = get_email_subject(plugin.configuration,constants.ORDER_CANCELED_SUBJECT_FIELD,@@ -277,6 +316,9 @@ def send_order_refund(payload: dict, config: dict, plugin: "UserEmailPlugin"):constants.ORDER_REFUND_CONFIRMATION_DEFAULT_TEMPLATE,constants.DEFAULT_EMAIL_TEMPLATES_PATH,)+ if not template:+ # Empty template means that we don't want to trigger a given event.+ returnsubject = get_email_subject(plugin.configuration,constants.ORDER_REFUND_CONFIRMATION_SUBJECT_FIELD,@@ -295,6 +337,9 @@ def send_order_confirmed(payload: dict, config: dict, plugin: "UserEmailPlugin")constants.ORDER_CONFIRMED_DEFAULT_TEMPLATE,constants.DEFAULT_EMAIL_TEMPLATES_PATH,)+ if not template:+ # Empty template means that we don't want to trigger a given event.+ returnsubject = get_email_subject(plugin.configuration,constants.ORDER_CONFIRMED_SUBJECT_FIELD,diff --git a/saleor/plugins/user_email/plugin.py b/saleor/plugins/user_email/plugin.pyindex a6cb562e2b..e9a78d36e9 100644--- a/saleor/plugins/user_email/plugin.py+++ b/saleor/plugins/user_email/plugin.py@@ -1,6 +1,6 @@import logging-from dataclasses import asdict, dataclass-from typing import TYPE_CHECKING, List, Optional, Union+from dataclasses import asdict+from typing import TYPE_CHECKING, List, Unionfrom promise.promise import Promise@@ -45,55 +45,6 @@ if TYPE_CHECKING:logger = logging.getLogger(__name__)-@dataclass-class UserTemplate:- account_confirmation: Optional[str]- account_set_customer_password: Optional[str]- account_delete: Optional[str]- account_change_email_confirm: Optional[str]- account_change_email_request: Optional[str]- account_password_reset: Optional[str]- invoice_ready: Optional[str]- order_confirmation: Optional[str]- order_confirmed: Optional[str]- order_fulfillment_confirmation: Optional[str]- order_fulfillment_update: Optional[str]- order_payment_confirmation: Optional[str]- order_canceled: Optional[str]- order_refund_confirmation: Optional[str]- send_gift_card: Optional[str]---def get_user_template_map(templates: UserTemplate):- return {- UserNotifyEvent.ACCOUNT_CONFIRMATION: templates.account_confirmation,- UserNotifyEvent.ACCOUNT_SET_CUSTOMER_PASSWORD: (- templates.account_set_customer_password- ),- UserNotifyEvent.ACCOUNT_DELETE: templates.account_delete,- UserNotifyEvent.ACCOUNT_CHANGE_EMAIL_CONFIRM: (- templates.account_change_email_confirm- ),- UserNotifyEvent.ACCOUNT_CHANGE_EMAIL_REQUEST: (- templates.account_change_email_request- ),- UserNotifyEvent.ACCOUNT_PASSWORD_RESET: templates.account_password_reset,- UserNotifyEvent.INVOICE_READY: templates.invoice_ready,- UserNotifyEvent.ORDER_CONFIRMATION: templates.order_confirmation,- UserNotifyEvent.ORDER_CONFIRMED: templates.order_confirmed,- UserNotifyEvent.ORDER_FULFILLMENT_CONFIRMATION: (- templates.order_fulfillment_confirmation- ),- UserNotifyEvent.ORDER_FULFILLMENT_UPDATE: templates.order_fulfillment_update,- UserNotifyEvent.ORDER_PAYMENT_CONFIRMATION: (- templates.order_payment_confirmation- ),- UserNotifyEvent.ORDER_CANCELED: templates.order_canceled,- UserNotifyEvent.ORDER_REFUND_CONFIRMATION: templates.order_refund_confirmation,- UserNotifyEvent.SEND_GIFT_CARD: templates.send_gift_card,- }--def get_user_event_map():return {UserNotifyEvent.ACCOUNT_CONFIRMATION: send_account_confirmation,@@ -402,43 +353,6 @@ class UserEmailPlugin(BasePlugin):use_tls=configuration["use_tls"],use_ssl=configuration["use_ssl"],)- self.templates = UserTemplate(- account_confirmation=configuration[- constants.ACCOUNT_CONFIRMATION_TEMPLATE_FIELD- ],- account_set_customer_password=configuration[- constants.ACCOUNT_SET_CUSTOMER_PASSWORD_TEMPLATE_FIELD- ],- account_delete=configuration[constants.ACCOUNT_DELETE_TEMPLATE_FIELD],- account_change_email_confirm=configuration[- constants.ACCOUNT_CHANGE_EMAIL_CONFIRM_TEMPLATE_FIELD- ],- account_change_email_request=configuration[- constants.ACCOUNT_CHANGE_EMAIL_REQUEST_TEMPLATE_FIELD- ],- account_password_reset=configuration[- constants.ACCOUNT_PASSWORD_RESET_TEMPLATE_FIELD- ],- invoice_ready=configuration[constants.INVOICE_READY_TEMPLATE_FIELD],- order_confirmation=configuration[- constants.ORDER_CONFIRMATION_TEMPLATE_FIELD- ],- order_confirmed=configuration[constants.ORDER_CONFIRMED_TEMPLATE_FIELD],- order_fulfillment_confirmation=configuration[- constants.ORDER_FULFILLMENT_CONFIRMATION_TEMPLATE_FIELD- ],- order_fulfillment_update=configuration[- constants.ORDER_FULFILLMENT_UPDATE_TEMPLATE_FIELD- ],- order_payment_confirmation=configuration[- constants.ORDER_PAYMENT_CONFIRMATION_TEMPLATE_FIELD- ],- order_canceled=configuration[constants.ORDER_CANCELED_TEMPLATE_FIELD],- order_refund_confirmation=configuration[- constants.ORDER_REFUND_CONFIRMATION_TEMPLATE_FIELD- ],- send_gift_card=configuration[constants.SEND_GIFT_CARD_TEMPLATE_FIELD],- )def resolve_plugin_configuration(self, request@@ -486,10 +400,6 @@ class UserEmailPlugin(BasePlugin):logger.warning(f"Missing handler for event {event}")return previous_value- template_map = get_user_template_map(self.templates)- if not template_map.get(event):- return previous_value-event_func = event_map[event]config = asdict(self.config) # type: ignoreevent_func(payload, config, self)diff --git a/saleor/plugins/user_email/tests/test_notify_events.py b/saleor/plugins/user_email/tests/test_notify_events.pyindex 3b6c70776f..d530742dd5 100644--- a/saleor/plugins/user_email/tests/test_notify_events.py+++ b/saleor/plugins/user_email/tests/test_notify_events.py@@ -47,6 +47,30 @@ def test_send_account_password_reset_event()+ "saleor.plugins.user_email.notify_events.send_password_reset_email_task.delay"+)+def test_send_account_password_reset_event_with_empty_template(+ mocked_email_task, customer_user, user_email_plugin+):+ token = "token123"+ payload = {+ "user": get_default_user_payload(customer_user),+ "recipient_email": "[email protected]",+ "token": token,+ "reset_url": f"http://localhost:8000/redirect{token}",+ "domain": "localhost:8000",+ "site_name": "Saleor",+ }+ config = {"host": "localhost", "port": "1025"}+ send_account_password_reset_event(+ payload=payload,+ config=config,+ plugin=user_email_plugin(password_reset_template=""),+ )+ assert not mocked_email_task.called++@mock.patch("saleor.plugins.user_email.notify_events.send_account_confirmation_email_task.delay")@@ -69,6 +93,30 @@ def test_send_account_confirmation(mocked_email_task, customer_user, user_email_)+ "saleor.plugins.user_email.notify_events.send_account_confirmation_email_task.delay"+)+def test_send_account_confirmation_with_empty_template(+ mocked_email_task, customer_user, user_email_plugin+):+ token = "token123"+ payload = {+ "user": get_default_user_payload(customer_user),+ "recipient_email": "[email protected]",+ "token": token,+ "confirm_url": f"http://localhost:8000/redirect{token}",+ "domain": "localhost:8000",+ "site_name": "Saleor",+ }+ config = {"host": "localhost", "port": "1025"}+ send_account_confirmation(+ payload=payload,+ config=config,+ plugin=user_email_plugin(account_confirmation_template=""),+ )+ assert not mocked_email_task.called++@mock.patch("saleor.plugins.user_email.notify_events.send_request_email_change_email_task.delay")@@ -95,6 +143,32 @@ def test_send_account_change_email_request()+ "saleor.plugins.user_email.notify_events.send_request_email_change_email_task.delay"+)+def test_send_account_change_email_request_empty_template(+ mocked_email_task, customer_user, user_email_plugin+):+ token = "token123"+ payload = {+ "user": get_default_user_payload(customer_user),+ "recipient_email": "[email protected]",+ "token": token,+ "redirect_url": f"http://localhost:8000/redirect{token}",+ "old_email": "[email protected]",+ "new_email": "[email protected]",+ "site_name": "Saleor",+ "domain": "localhost:8000",+ }+ config = {"host": "localhost", "port": "1025"}+ send_account_change_email_request(+ payload=payload,+ config=config,+ plugin=user_email_plugin(email_change_request_template=""),+ )+ assert not mocked_email_task.called++@mock.patch("saleor.plugins.user_email.notify_events.send_user_change_email_notification_task.""delay"@@ -117,6 +191,28 @@ def test_send_account_change_email_confirm()+ "saleor.plugins.user_email.notify_events.send_user_change_email_notification_task."+ "delay"+)+def test_send_account_change_email_confirm_empty_template(+ mocked_email_task, customer_user, user_email_plugin+):+ payload = {+ "user": get_default_user_payload(customer_user),+ "recipient_email": "[email protected]",+ "site_name": "Saleor",+ "domain": "localhost:8000",+ }+ config = {"host": "localhost", "port": "1025"}+ send_account_change_email_confirm(+ payload=payload,+ config=config,+ plugin=user_email_plugin(email_change_confirm_template=""),+ )+ assert not mocked_email_task.called++@mock.patch("saleor.plugins.user_email.notify_events.""send_account_delete_confirmation_email_task.delay"@@ -138,6 +234,31 @@ def test_send_account_delete(mocked_email_task, customer_user, user_email_plugin)+ "saleor.plugins.user_email.notify_events."+ "send_account_delete_confirmation_email_task.delay"+)+def test_send_account_delete_with_empty_template(+ mocked_email_task, customer_user, user_email_plugin+):+ token = "token123"+ payload = {+ "user": get_default_user_payload(customer_user),+ "recipient_email": "[email protected]",+ "token": token,+ "delete_url": f"http://localhost:8000/redirect{token}",+ "site_name": "Saleor",+ "domain": "localhost:8000",+ }+ config = {"host": "localhost", "port": "1025"}+ send_account_delete(+ payload=payload,+ config=config,+ plugin=user_email_plugin(account_delete_template=""),+ )+ assert not mocked_email_task.called++@mock.patch("saleor.plugins.user_email.notify_events.send_set_user_password_email_task.delay")@@ -162,6 +283,30 @@ def test_send_account_set_customer_password()+ "saleor.plugins.user_email.notify_events.send_set_user_password_email_task.delay"+)+def test_send_account_set_customer_password_empty_template(+ mocked_email_task, customer_user, user_email_plugin+):+ token = "token123"+ payload = {+ "user": get_default_user_payload(customer_user),+ "recipient_email": "[email protected]",+ "token": token,+ "password_set_url": f"http://localhost:8000/redirect{token}",+ "site_name": "Saleor",+ "domain": "localhost:8000",+ }+ config = {"host": "localhost", "port": "1025"}+ send_account_set_customer_password(+ payload=payload,+ config=config,+ plugin=user_email_plugin(account_set_password_template=""),+ )+ assert not mocked_email_task.called++@mock.patch("saleor.plugins.user_email.notify_events.send_invoice_email_task.delay")def test_send_invoice(mocked_email_task, user_email_plugin):payload = {@@ -181,6 +326,27 @@ def test_send_invoice(mocked_email_task, user_email_plugin):)[email protected]("saleor.plugins.user_email.notify_events.send_invoice_email_task.delay")+def test_send_invoice_with_empty_template(mocked_email_task, user_email_plugin):+ payload = {+ "invoice": {+ "id": 1,+ "number": 999,+ "download_url": "http://localhost:8000/download",+ },+ "recipient_email": "[email protected]",+ "site_name": "Saleor",+ "domain": "localhost:8000",+ }+ config = {"host": "localhost", "port": "1025"}+ send_invoice(+ payload=payload,+ config=config,+ plugin=user_email_plugin(invoice_ready_template=""),+ )+ assert not mocked_email_task.called++@mock.patch("saleor.plugins.user_email.notify_events.send_order_confirmation_email_task.delay")@@ -198,6 +364,27 @@ def test_send_order_confirmation(mocked_email_task, order, user_email_plugin):)+ "saleor.plugins.user_email.notify_events.send_order_confirmation_email_task.delay"+)+def test_send_order_confirmation_empty_template(+ mocked_email_task, order, user_email_plugin+):+ payload = {+ "order": get_default_order_payload(order, "http://localhost:8000/redirect"),+ "recipient_email": "[email protected]",+ "site_name": "Saleor",+ "domain": "localhost:8000",+ }+ config = {"host": "localhost", "port": "1025"}+ send_order_confirmation(+ payload=payload,+ config=config,+ plugin=user_email_plugin(order_confirmation_template=""),+ )+ assert not mocked_email_task.called++@mock.patch("saleor.plugins.user_email.notify_events.send_fulfillment_confirmation_email_task.""delay"@@ -215,6 +402,23 @@ def test_send_fulfillment_confirmation()+ "saleor.plugins.user_email.notify_events.send_fulfillment_confirmation_email_task."+ "delay"+)+def test_send_fulfillment_confirmation_empty_template(+ mocked_email_task, order, fulfillment, user_email_plugin+):+ payload = get_default_fulfillment_payload(order, fulfillment)+ config = {"host": "localhost", "port": "1025"}+ send_fulfillment_confirmation(+ payload=payload,+ config=config,+ plugin=user_email_plugin(fulfillment_confirmation_template=""),+ )+ assert not mocked_email_task.called++@mock.patch("saleor.plugins.user_email.notify_events.send_fulfillment_update_email_task.delay")@@ -229,6 +433,22 @@ def test_send_fulfillment_update()+ "saleor.plugins.user_email.notify_events.send_fulfillment_update_email_task.delay"+)+def test_send_fulfillment_update_empty_template(+ mocked_email_task, order, fulfillment, user_email_plugin+):+ payload = get_default_fulfillment_payload(order, fulfillment)+ config = {"host": "localhost", "port": "1025"}+ send_fulfillment_update(+ payload=payload,+ config=config,+ plugin=user_email_plugin(fulfillment_update_template=""),+ )+ assert not mocked_email_task.called++@mock.patch("saleor.plugins.user_email.notify_events.send_payment_confirmation_email_task.delay")@@ -258,6 +478,35 @@ def test_send_payment_confirmation()+ "saleor.plugins.user_email.notify_events.send_payment_confirmation_email_task.delay"+)+def test_send_payment_confirmation_empty_template(+ mocked_email_task, order, payment_dummy, user_email_plugin+):+ payload = {+ "order": get_default_order_payload(order, "http://localhost:8000/redirect"),+ "recipient_email": "[email protected]",+ "payment": {+ "created": payment_dummy.created,+ "modified": payment_dummy.modified,+ "charge_status": payment_dummy.charge_status,+ "total": payment_dummy.total,+ "captured_amount": payment_dummy.captured_amount,+ "currency": payment_dummy.currency,+ },+ "site_name": "Saleor",+ "domain": "localhost:8000",+ }+ config = {"host": "localhost", "port": "1025"}+ send_payment_confirmation(+ payload=payload,+ config=config,+ plugin=user_email_plugin(payment_confirmation_template=""),+ )+ assert not mocked_email_task.called++@mock.patch("saleor.plugins.user_email.notify_events.send_order_canceled_email_task.delay")@@ -275,6 +524,27 @@ def test_send_order_canceled(mocked_email_task, order, user_email_plugin):)+ "saleor.plugins.user_email.notify_events.send_order_canceled_email_task.delay"+)+def test_send_order_canceled_empty_template(+ mocked_email_task, order, user_email_plugin+):+ payload = {+ "order": get_default_order_payload(order, "http://localhost:8000/redirect"),+ "recipient_email": "[email protected]",+ "site_name": "Saleor",+ "domain": "localhost:8000",+ }+ config = {"host": "localhost", "port": "1025"}+ send_order_canceled(+ payload=payload,+ config=config,+ plugin=user_email_plugin(order_cancel_template=""),+ )+ assert not mocked_email_task.called++@mock.patch("saleor.plugins.user_email.notify_events.send_order_refund_email_task.delay")@@ -294,6 +564,29 @@ def test_send_order_refund(mocked_email_task, order, user_email_plugin):)+ "saleor.plugins.user_email.notify_events.send_order_refund_email_task.delay"+)+def test_send_order_refund_with_empty_template(+ mocked_email_task, order, user_email_plugin+):+ payload = {+ "order": get_default_order_payload(order, "http://localhost:8000/redirect"),+ "recipient_email": "[email protected]",+ "amount": order.total_gross_amount,+ "currency": order.currency,+ "site_name": "Saleor",+ "domain": "localhost:8000",+ }+ config = {"host": "localhost", "port": "1025"}+ send_order_refund(+ payload=payload,+ config=config,+ plugin=user_email_plugin(order_refund_template=""),+ )+ assert not mocked_email_task.called++@mock.patch("saleor.plugins.user_email.notify_events.send_order_confirmed_email_task.delay")@@ -309,3 +602,24 @@ def test_send_order_confirmed(mocked_email_task, order, user_email_plugin):mocked_email_task.assert_called_with(payload["recipient_email"], payload, config, mock.ANY, mock.ANY)+++ "saleor.plugins.user_email.notify_events.send_order_confirmed_email_task.delay"+)+def test_send_order_confirmed_empty_template(+ mocked_email_task, order, user_email_plugin+):+ payload = {+ "order": get_default_order_payload(order, "http://localhost:8000/redirect"),+ "recipient_email": "[email protected]",+ "site_name": "Saleor",+ "domain": "localhost:8000",+ }+ config = {"host": "localhost", "port": "1025"}+ send_order_confirmed(+ payload=payload,+ config=config,+ plugin=user_email_plugin(order_confirmed_template=""),+ )+ assert not mocked_email_task.called