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)
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, "*****@*****.**", ['*****@*****.**'])