Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fill email context with proper data
Jakub Draganek1f8febd827ea
diff --git a/saleor/order/emails.py b/saleor/order/emails.pyindex 0ab0c6e80a..8b1de59d88 100644--- a/saleor/order/emails.py+++ b/saleor/order/emails.py@@ -1,9 +1,14 @@from templated_email import send_templated_mail+from ..site.utils import get_site_name+from django.conf import settings-CONFIRMATION_TEMPLATE = 'foo'+CONFIRMATION_TEMPLATE = 'order/confirm_order'-def send_confirmation(address):- send_templated_mail(from_email=address, recipient_list=[], context={},+def send_confirmation(address, url):+ send_templated_mail(from_email=settings.ORDER_FROM_EMAIL,+ recipient_list=[address],+ context={'site_name': get_site_name(),+ 'payment_url': url},template_name=CONFIRMATION_TEMPLATE)diff --git a/tests/test_emails.py b/tests/test_emails.pyindex c8b0ae407b..9458115d75 100644--- a/tests/test_emails.py+++ b/tests/test_emails.py@@ -1,17 +1,23 @@from __future__ import unicode_literals+from django.conf import settingsimport saleor.order.emails as emailsimport pytestimport mock-EMAIL_DATA = {'from_email': '[email protected]',+EMAIL_DATA = {'from_email': settings.ORDER_FROM_EMAIL,'template_name': emails.CONFIRMATION_TEMPLATE}[email protected]('saleor.order.emails.get_site_name', return_value='WOOBALOOBA')@mock.patch('saleor.order.emails.send_templated_mail')-def test_send_confirmation_using_templated_email(mocked_templated_email):- emails.send_confirmation(EMAIL_DATA['from_email'])- mocked_templated_email.assert_called_once_with(recipient_list=[],- context={},- **EMAIL_DATA)+def test_send_confirmation_using_templated_email(mocked_templated_email,+ mocked_get_site_name):+ email_address = '[email protected]'+ url = 'wooba/looba'+ emails.send_confirmation(email_address, url)+ context = {'site_name': mocked_get_site_name(),+ 'payment_url': url}+ mocked_templated_email.assert_called_once_with(+ recipient_list=[email_address], context=context, **EMAIL_DATA)