Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add test for collecting email data
akjanik3711528c68b3
diff --git a/saleor/dashboard/order/forms.py b/saleor/dashboard/order/forms.pyindex 56afdfa234..67d4ce177b 100644--- a/saleor/dashboard/order/forms.py+++ b/saleor/dashboard/order/forms.py@@ -1,17 +1,18 @@from django import formsfrom django.conf import settingsfrom django.core.validators import MaxValueValidator, MinValueValidator-from django.urls import reverse, reverse_lazy+from django.urls import reverse_lazyfrom django.utils.translation import npgettext_lazy, pgettext_lazyfrom django_prices.forms import PriceFieldfrom payments import PaymentError, PaymentStatus+from ...account.i18n import (+ AddressForm as StorefrontAddressForm, PossiblePhoneNumberFormField)from ...cart.forms import QuantityFieldfrom ...core.exceptions import InsufficientStock-from ...core.utils import build_absolute_urifrom ...discount.utils import decrease_voucher_usagefrom ...order import GroupStatus-from ...order.emails import send_note_confirmation+from ...order.emails import collect_data_for_email, send_note_confirmationfrom ...order.models import DeliveryGroup, OrderLine, OrderNotefrom ...order.utils import (add_variant_to_delivery_group, cancel_order, change_order_line_quantity,@@ -19,8 +20,6 @@ from ...order.utils import (recalculate_order, remove_empty_groups)from ...product.models import Product, ProductVariant, Stockfrom ...product.utils import allocate_stock, deallocate_stock-from ...account.i18n import (- AddressForm as StorefrontAddressForm, PossiblePhoneNumberFormField)from ..forms import AjaxSelect2ChoiceFieldfrom ..widgets import PhonePrefixWidget@@ -39,11 +38,8 @@ class OrderNoteForm(forms.ModelForm):def send_confirmation_email(self):order = self.instance.order- email = order.get_user_current_email()- url = build_absolute_uri(- reverse(- 'order:details', kwargs={'token': order.token}))- send_note_confirmation.delay(email, url)+ email_data = collect_data_for_email(order)+ send_note_confirmation.delay(**email_data)class ManagePaymentForm(forms.Form):diff --git a/tests/test_order.py b/tests/test_order.pyindex 1afd02636c..da8801719b 100644--- a/tests/test_order.py+++ b/tests/test_order.py@@ -5,6 +5,7 @@ from prices import Pricefrom tests.utils import get_redirect_locationfrom saleor.order import OrderStatus, models+from saleor.order.emails import collect_data_for_emailfrom saleor.order.forms import OrderNoteFormfrom saleor.order.utils import (add_variant_to_delivery_group, create_history_entry)@@ -179,3 +180,12 @@ def test_delivery_group_is_shipping_required_partially_required(unit_price_net=Decimal('30.00'),unit_price_gross=Decimal('30.00'))assert delivery_group.is_shipping_required()+++def test_collect_data_for_email(order):+ order = order+ order.user_mail = '[email protected]'+ email_data = collect_data_for_email(order)+ order_url = reverse('order:details', kwargs={'token': order.token})+ assert order_url in email_data['url']+ assert email_data['email'] == order.user_email