diff --git a/api/desecapi/tests/test_donations.py b/api/desecapi/tests/test_donations.py index 3ce6585fd..40fc85e4a 100644 --- a/api/desecapi/tests/test_donations.py +++ b/api/desecapi/tests/test_donations.py @@ -20,7 +20,34 @@ def test_create_donation_minimal(self): } response = self.client.post(url, data) self.assertTrue(mail.outbox) - email_internal = str(mail.outbox[0].message()) + + import copy + from base64 import b64encode + from django.core.mail.message import SafeMIMEText + + class Mock(SafeMIMEText): + def __new__(cls, *args, **kwargs): + if args and isinstance(args[0], SafeMIMEText): + other = copy.copy(args[0]) + other.__class__ = Mock + return other + return object.__new__(cls) + + def __init__(self, other): + pass + + def set_payload(self, payload, *args, **kwargs): + print("set_payload", b64encode(payload.encode())) + + msg = mail.outbox[0].message() + msg._payload = [Mock(o) for o in msg._payload] + #print(msg._payload) + #print( + # "DEBUG1", + # [b64encode(o.as_bytes()) for o in msg._payload], + #) + #print("DEBUG2", b64encode(msg.as_bytes())) + email_internal = str(msg) direct_debit = str(mail.outbox[0].attachments[0][1]) reply_to = mail.outbox[0].reply_to self.assertStatus(response, status.HTTP_201_CREATED)