-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updates to email templates for post_office compatibility (#752)
[#188743887]
- Loading branch information
1 parent
e1eb633
commit 2a93d7d
Showing
4 changed files
with
41 additions
and
59 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
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 |
---|---|---|
|
@@ -14,23 +14,22 @@ | |
|
||
AuthUser = get_user_model() | ||
|
||
TEST_AUTH_MAIL_TEMPLATE = post_office.models.EmailTemplate( | ||
content='user:{{user}}\nurl:{{reset_url}}\npassword_reset_url:{{password_reset_url}}' | ||
) | ||
|
||
|
||
@override_settings(EMAIL_FROM_USER='[email protected]') | ||
class TestRegistrationFlow(TestCase): | ||
def setUp(self): | ||
self.factory = RequestFactory() | ||
self.template = post_office.models.EmailTemplate.objects.create( | ||
content='user:{{user}}\nurl:{{confirmation_url}}\npassword_reset_url:{{password_reset_url}}' | ||
) | ||
|
||
def test_registration_flow(self): | ||
request = self.factory.post(reverse('tracker:register')) | ||
new_user = AuthUser.objects.create( | ||
username='dummyuser', email='[email protected]', is_active=False | ||
) | ||
sent_mail = tracker.auth.send_registration_mail( | ||
request, new_user, template=TEST_AUTH_MAIL_TEMPLATE | ||
request, new_user, template=self.template | ||
) | ||
contents = util.parse_test_mail(sent_mail) | ||
self.assertEqual(new_user.username, contents['user'][0]) | ||
|
@@ -62,6 +61,17 @@ def test_registration_flow(self): | |
self.assertTrue(new_user.is_active) | ||
self.assertTrue(new_user.check_password('foobar')) | ||
|
||
def test_reset_url_deprecation(self): | ||
with self.assertRaises(AssertionError): | ||
request = self.factory.post(reverse('tracker:register')) | ||
new_user = AuthUser.objects.create( | ||
username='dummyuser', email='[email protected]', is_active=False | ||
) | ||
template = post_office.models.EmailTemplate.objects.create( | ||
content='{{ reset_url }}' | ||
) | ||
tracker.auth.send_registration_mail(request, new_user, template=template) | ||
|
||
def test_register_inactive_user(self): | ||
AuthUser.objects.create( | ||
username='existinguser', email='[email protected]', is_active=False | ||
|
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
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