1616# app imports
1717from auth_enhanced .email import (
1818 AuthEnhancedEmail , callback_admin_information_new_signup ,
19+ callback_user_signup_email_verification ,
1920)
2021from auth_enhanced .settings import (
2122 DAE_CONST_MODE_AUTO_ACTIVATION , DAE_CONST_MODE_EMAIL_ACTIVATION ,
@@ -180,7 +181,7 @@ def test_callback_apply_mode_manual(self):
180181
181182 @override_settings (DAE_OPERATION_MODE = 'foo' )
182183 def test_callback_apply_mode_none (self ):
183- """Is ' context['mode_manual']' set?
184+ """With an invalid operation mode, no context is applied.
184185
185186 See 'callback_admin_information_new_signup()'-function."""
186187
@@ -200,3 +201,46 @@ def test_callback_apply_mode_none(self):
200201 mail .outbox [0 ].body
201202 )
202203 self .assertNotIn ('uses a signup system that requires the manual activation of accounts' , mail .outbox [0 ].body )
204+
205+
206+ @tag ('email' )
207+ @override_settings (
208+ DAE_ADMIN_SIGNUP_NOTIFICATION = (('django' , 'django@localhost' , ('mail' , )), ),
209+ DAE_EMAIL_PREFIX = '' ,
210+ DAE_OPERATION_MODE = DAE_CONST_MODE_EMAIL_ACTIVATION
211+ )
212+ class UserSignupEmailVerificationTests (AuthEnhancedTestCase ):
213+ """These tests target the 'callback_user_signup_email_verification'-function."""
214+
215+ def test_callback_not_created (self ):
216+ """If this is not a newly created object, do nothing.
217+
218+ See 'callback_user_signup_email_verification()'-function."""
219+
220+ retval = callback_user_signup_email_verification (
221+ get_user_model (),
222+ None ,
223+ False , # this is the relevant 'created' parameter!
224+ )
225+ self .assertFalse (retval )
226+
227+ @tag ('current' )
228+ @override_settings (DAE_EMAIL_PREFIX = 'foo' )
229+ def test_callback_subject_prefix (self ):
230+ """Is the subject line modified?
231+
232+ See 'callback_user_signup_email_verification()'-function."""
233+
234+ # create a User object to pass along
235+ u = get_user_model ().objects .create (username = 'foo' , email = 'foo@localhost' )
236+
237+ retval = callback_user_signup_email_verification (
238+ get_user_model (),
239+ u ,
240+ True
241+ )
242+ self .assertTrue (retval )
243+ self .assertEqual (len (mail .outbox ), 1 )
244+ self .assertEqual (mail .outbox [0 ].subject , '[{}] Email Verification Mail' .format (
245+ settings .DAE_EMAIL_PREFIX
246+ ))
0 commit comments