예제 #1
0
 def test_handle_successful_order_no_email_opt_in(self, _):
     """
     Verify that the post checkout defaults email_opt_in to false.
     """
     with mock.patch('ecommerce.extensions.checkout.mixins.post_checkout.send') as mock_send:
         mixin = EdxOrderPlacementMixin()
         mixin.handle_successful_order(self.order)
         send_arguments = {'sender': mixin, 'order': self.order, 'request': None, 'email_opt_in': False}
         mock_send.assert_called_once_with(**send_arguments)
예제 #2
0
    def test_handle_successful_order_with_email_opt_in(self, expected_opt_in, _):
        """
        Verify that the post checkout sets email_opt_in if it is given.
        """
        BasketAttribute.objects.get_or_create(
            basket=self.order.basket,
            attribute_type=BasketAttributeType.objects.get(name=EMAIL_OPT_IN_ATTRIBUTE),
            value_text=expected_opt_in,
        )

        with mock.patch('ecommerce.extensions.checkout.mixins.post_checkout.send') as mock_send:
            mixin = EdxOrderPlacementMixin()
            mixin.handle_successful_order(self.order)
            send_arguments = {
                'sender': mixin,
                'order': self.order,
                'request': None,
                'email_opt_in': expected_opt_in,
            }
            mock_send.assert_called_once_with(**send_arguments)