Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
peterthomassen committed Apr 12, 2024
1 parent a1374d1 commit e6d6a3a
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,12 @@ jobs:
uses: ./.github/workflows/build
with:
images: api dbapi nslord nsmaster dblord dbmaster
- name: Pin Python version
uses: actions/setup-python@v5
with:
python-version: '3.11.8'
- name: Run API Tests
run: docker-compose -f docker-compose.yml -f docker-compose.test-api.yml run -T api bash -c "./entrypoint-tests.sh"
run: docker-compose -f docker-compose.yml -f docker-compose.test-api.yml run -T api bash -c "python --version && python3 --version && ./entrypoint-tests.sh"
- name: API Tests Logs and Cleanup
if: always()
run: |
Expand Down
2 changes: 1 addition & 1 deletion api/desecapi/templates/emails/donation/desec-content.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Woha,

{{ donation.name }} <{{ donation.email }}> hat {{ donation.amount }} gespendet.
{{ donation.name }} <{{ donation.email }}> hat {{ donation.amount }}EUR gespendet.

Häufigkeit: alle {{ donation.interval }} Monate

Expand Down
34 changes: 33 additions & 1 deletion api/desecapi/tests/test_donations.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,39 @@ 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",
type(payload),
payload.encode(errors="backslashreplace"),
)
return super().set_payload(payload, *args, **kwargs)

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 e6d6a3a

Please sign in to comment.