from unittest import mock

from django.conf import settings

import saleor.order.emails as emails

EMAIL = "foo@bar.com"
SITE_NAME = 'mirumee.com'
URL = 'wooba/looba'
EMAIL_FROM = settings.ORDER_FROM_EMAIL


@mock.patch('saleor.order.emails.send_templated_mail')
def test_send_confirmation_using_templated_email(
        mocked_templated_email, order):
    emails.send_order_confirmation(EMAIL, URL, order.pk)
    context = {'site_name': SITE_NAME, 'url': URL, 'order': order}
    mocked_templated_email.assert_called_once_with(
        recipient_list=[EMAIL],
        context=context,
        from_email=EMAIL_FROM,
        template_name=emails.CONFIRM_ORDER_TEMPLATE)


@mock.patch('saleor.order.emails.send_templated_mail')
def test_send_order_payment_confirmation(mocked_templated_email):
    emails.send_payment_confirmation(EMAIL, URL)
    context = {'site_name': SITE_NAME, 'url': URL}
    mocked_templated_email.assert_called_once_with(
        recipient_list=[EMAIL],
        context=context,
        from_email=EMAIL_FROM,
        template_name=emails.CONFIRM_PAYMENT_TEMPLATE)


@mock.patch('saleor.order.emails.send_templated_mail')
def test_send_note_confirmation(mocked_templated_email):
    emails.send_note_confirmation(EMAIL, URL)
    context = {'site_name': SITE_NAME, 'url': URL}
    mocked_templated_email.assert_called_once_with(
        recipient_list=[EMAIL],
        context=context,
        from_email=EMAIL_FROM,
        template_name=emails.CONFIRM_NOTE_TEMPLATE)

@@ -114,16 +114,39 @@
 ar.com%22%0A
+DOMAIN = 'mirumee.com'%0A
 SITE_NAM
@@ -433,32 +433,95 @@
 %0A    context = %7B
+%0A        'protocol': 'http',%0A        'domain': DOMAIN,%0A        
 'site_name': SIT
@@ -519,32 +519,40 @@
 ame': SITE_NAME,
+%0A       
  'url': URL, 'or
@@ -547,16 +547,24 @@
 l': URL,
+%0A       
  'order'
@@ -944,32 +944,95 @@
 %0A    context = %7B
+%0A        'protocol': 'http',%0A        'domain': DOMAIN,%0A        
 'site_name': SIT
@@ -1030,32 +1030,40 @@
 ame': SITE_NAME,
+%0A       
  'url': URL%7D%0A   
@@ -1429,16 +1429,79 @@
 text = %7B
+%0A        'protocol': 'http',%0A        'domain': DOMAIN,%0A        
 'site_na
@@ -1515,16 +1515,24 @@
 TE_NAME,
+%0A       
  'url': 

Fix failing e-mail tests