Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
peterthomassen committed Apr 11, 2024
1 parent a1374d1 commit e715f5f
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion api/desecapi/tests/test_donations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e715f5f

Please sign in to comment.