This repository has been archived by the owner on Nov 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix accepted mail sending when present in eventsignups POST (#416)
* 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
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|