WIP: Attach invoice PDF to payment emails #104418

Draft
Anna Sirota wants to merge 4 commits from attach-invoice-pdf into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Showing only changes of commit 1ffbe677cd - Show all commits

View File

@ -0,0 +1,72 @@
from unittest.mock import patch, Mock, call
import datetime
from django.test import TestCase
import django.core.mail
import responses
from looper.tests.factories import SubscriptionFactory
from common.tests.factories.users import UserFactory
import subscriptions.tasks as tasks
@patch(
'subscriptions.tasks.send_mail_bank_transfer_required',
new=tasks.send_mail_bank_transfer_required.task_function,
)
@patch(
'subscriptions.tasks.send_mail_subscription_status_changed',
new=tasks.send_mail_subscription_status_changed.task_function,
)
@patch(
'subscriptions.tasks.send_mail_automatic_payment_performed',
new=tasks.send_mail_automatic_payment_performed.task_function,
)
@patch(
'subscriptions.tasks.send_mail_managed_subscription_notification',
new=tasks.send_mail_managed_subscription_notification.task_function,
)
@patch(
'subscriptions.tasks.send_mail_subscription_expired',
new=tasks.send_mail_subscription_expired.task_function,
)
@patch(
'subscriptions.tasks.send_mail_no_payment_method',
new=tasks.send_mail_no_payment_method.task_function,
)
class TestSubscriptionSignals(TestCase):
def test_subscription_created_needs_payment(self):
subscription = SubscriptionFactory(status='on-hold', collection_method='manual')
the_mail: django.core.mail.message.EmailMultiAlternatives = django.core.mail.outbox[-1]
self.assertIn(self.user.customer.billing_address.full_name, the_mail.body)
alt0_body, alt0_type = the_mail.alternatives[0]
self.assertEqual(alt0_type, 'text/html')
def test_automatic_payment_failed(self):
pass
def test_automatic_payment_failed_no_payment_method(self):
pass
def test_automatic_payment_soft_failed(self):
pass
def test_automatic_payment_soft_failed_no_payment_method(self):
pass
def test_automatic_payment_succesful(self):
pass
def test_managed_subscription_notification(self):
pass
def test_subscription_activated(self):
pass
def test_subscription_deactivated(self):
pass
def test_subscription_expired(self):
pass