コード例 #1
0
    def test_reset_password_saves_new_password(self, mock_send_email):
        district = Location(**dict(name='Kampala', parent=None, type='district'))
        district.save()
        profile = UserProfile(name='Andrew', email='*****@*****.**', location=district, phone='2570760540326')
        user = UserProfileService(profile).setup_new_user('andrew', str((Group.objects().first()).id))
        old_password = user.password
        profile.user = user

        UserProfileService(profile).reset_password()
        self.assertNotEqual(old_password, profile.user.password)
コード例 #2
0
    def test_password_reset_sends_email(self, mock_send_mail, mock_make_password):
        message = "Andrew blabla http://necoc.org.ug [email protected]"
        mock_make_password.return_value = 'blabla'
        district = Location(**dict(name='Kampala', parent=None, type='district'))
        district.save()
        profile = UserProfile(name='Andrew', email='*****@*****.**', location=district, phone='2570760540326')
        user = UserProfileService(profile).setup_new_user('andrew', str((Group.objects().first()).id))
        profile.user = user

        UserProfileService(profile).reset_password()
        mock_send_mail.assert_any_call('NECOC Password Reset',
                                       message,
                                       "*****@*****.**",
                                       ['*****@*****.**'])
コード例 #3
0
 def test_password_change_notification_sends_email(self, mock_send_mail):
     message = "Andrew http://necoc.org.ug [email protected]"
     profile = UserProfile(name='Andrew', email='*****@*****.**')
     UserProfileService(profile).notify_password_change()
     mock_send_mail.assert_called_with('Your NECOC Account',
                                       message,
                                       "*****@*****.**",
                                       ['*****@*****.**'])
コード例 #4
0
 def test_new_password_is_sent_in_email(self, mock_send_mail, mock_make_password):
     message = "Andrew http://necoc.org.ug andrew blabla"
     mock_make_password.return_value = 'blabla'
     profile = UserProfile(name='Andrew', email='*****@*****.**')
     group = Group.objects().first()
     UserProfileService(profile).setup_new_user('andrew', str(group.id))
     mock_send_mail.assert_called_with('Your NECOC Account',
                                       message,
                                       settings.DEFAULT_FROM_EMAIL,
                                       ['*****@*****.**'])
コード例 #5
0
 def pre_save(self, obj):
     profile = super(PasswordResetView, self).get_object()
     UserProfileService(profile).reset_password()
コード例 #6
0
 def pre_save(self, obj):
     profile = super(PasswordChangeView, self).get_object()
     UserProfileService(profile).notify_password_change()
コード例 #7
0
 def test_setup_new_user_saves_new_password(self, mock_send_mail):
     profile = UserProfile(name='Andrew', email='*****@*****.**')
     group = Group.objects().first()
     user = UserProfileService(profile).setup_new_user('andrew', str(group.id))
     self.assertIsNotNone(user.password)
コード例 #8
0
 def test_associates_group_to_user(self, mock_send_mail, mock_make_password):
     mock_make_password.return_value = 'blabla'
     profile = UserProfile(name='Andrew', email='*****@*****.**')
     group = Group.objects().first()
     user = UserProfileService(profile).setup_new_user('andrew', str(group.id))
     self.assertEqual(group, user.group)
コード例 #9
0
 def pre_save(self, obj):
     username = self.request.DATA.get('username', None)
     group_id = self.request.DATA.get('group', None)
     if username:
         user = UserProfileService(obj).setup_new_user(username, group_id)
         obj.user = user