Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
Fix accepted mail sending when present in eventsignups POST (#416)
Browse files Browse the repository at this point in the history
* Fix accepted mail sending when present in eventsignups POST

* Move test to test_emails.py

* Remove hook for notify_signup_accepted_on_inserted

* Add comments to email test to clarify its intention
  • Loading branch information
temparus authored Dec 17, 2023
1 parent ece574e commit 08bdef5
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions amivapi/tests/events/test_emails.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,53 @@ def test_no_nones_in_emails(self):
for field in mail.values():
self.assertTrue('None' not in field)

def test_signup_added_by_admin_accepted_emails(self):
"""Test that an accepted email is sent when an admin has added a
signup manually."""
event = self.new_object('events', spots=1, selection_strategy='fcfs',
allow_email_signup=True)

user = self.new_object('users')

self.api.post('/eventsignups', data={
'user': str(user['_id']),
'event': str(event['_id']),
'accepted': True
}, token=self.get_root_token(), status_code=201).json

mail = self.app.test_mails[0]
for field in mail.values():
# We check whether any field in the email structure contains the
# string 'None' as this is the string representation of the None
# value. This happens when a value inserted into the template
# string was (unexpectedly) None.
self.assertTrue('None' not in field)

self.assertTrue('accepted' in mail['subject'])

self.api.post('/eventsignups', data={
'email': '[email protected]',
'event': str(event['_id']),
'accepted': True
}, token=self.get_root_token(), status_code=201).json

# accepted email and confirmation email should be sent.
self.assertIs(len(self.app.test_mails), 3)
for mail in self.app.test_mails[1:]:
for field in mail.values():
# We check whether any field in the email structure contains the
# string 'None' as this is the string representation of the None
# value. This happens when a value inserted into the template
# string was (unexpectedly) None.
self.assertTrue('None' not in field)

# We expect that the accepted email and the email to confirm the
# email address were sent.
# We check some unique phrases distinct to each of these messages.
self.assertTrue(
('accepted' in mail['subject']) !=
('confirm_email' in mail['text']))

def test_calendar_invite_format(self):
"""Test that the calendar invite format.
Specifically looks for the correct line format and the presence of
Expand Down

0 comments on commit 08bdef5

Please sign in to comment.