Example #1
0
    def test_mail_send__to_system_user(self):
        from the_tale.accounts.logic import get_system_user

        Message.objects.all().delete()

        ResetPasswordTaskPrototype.create(get_system_user())
        message = MessagePrototype.get_priority_message()

        self.assertEqual(len(mail.outbox), 0)
        message.process()
        self.assertTrue(message.state.is_PROCESSED)
        self.assertEqual(len(mail.outbox), 0)
Example #2
0
    def test_mail_send__to_system_user(self):
        from the_tale.accounts.logic import get_system_user

        Message.objects.all().delete()

        ResetPasswordTaskPrototype.create(get_system_user())
        message = MessagePrototype.get_priority_message()

        self.assertEqual(len(mail.outbox), 0)
        message.process()
        self.assertTrue(message.state.is_PROCESSED)
        self.assertEqual(len(mail.outbox), 0)
Example #3
0
    def setUp(self):
        super(ResetPasswordTaskTests, self).setUp()

        create_test_map()

        self.account = self.accounts_factory.create_account()
        self.task = ResetPasswordTaskPrototype.create(self.account)
Example #4
0
    def setUp(self):
        super(ResetPasswordTaskTests, self).setUp()

        create_test_map()

        self.account = self.accounts_factory.create_account()
        self.task = ResetPasswordTaskPrototype.create(self.account)
Example #5
0
    def setUp(self):
        super(ResetPasswordTaskTests, self).setUp()
        create_test_map()

        result, account_id, bundle_id = register_user('test_user', '*****@*****.**', '111111')
        self.account = AccountPrototype.get_by_id(account_id)

        self.task = ResetPasswordTaskPrototype.create(self.account)
Example #6
0
    def setUp(self):
        super(ResetPasswordTests, self).setUp()
        create_test_map()

        register_user('user_1', '*****@*****.**', '111111')
        self.account_1 = AccountPrototype.get_by_nick('user_1')

        self.reset_task = ResetPasswordTaskPrototype.create(self.account_1)
        self.message = MessagePrototype.get_priority_message()
Example #7
0
    def setUp(self):
        super(ResetPasswordTests, self).setUp()
        create_test_map()

        register_user('user_1', '*****@*****.**', '111111')
        self.account_1 = AccountPrototype.get_by_nick('user_1')

        self.reset_task = ResetPasswordTaskPrototype.create(self.account_1)
        self.message = MessagePrototype.get_priority_message()
Example #8
0
    def setUp(self):
        super(ResetPasswordTests, self).setUp()

        create_test_map()

        self.account_1 = self.accounts_factory.create_account()

        self.reset_task = ResetPasswordTaskPrototype.create(self.account_1)
        self.message = MessagePrototype.get_priority_message()
Example #9
0
    def setUp(self):
        super(ResetPasswordTaskTests, self).setUp()
        create_test_map()

        result, account_id, bundle_id = register_user('test_user',
                                                      '*****@*****.**',
                                                      '111111')
        self.account = AccountPrototype.get_by_id(account_id)

        self.task = ResetPasswordTaskPrototype.create(self.account)
Example #10
0
    def test_reset_password_processed(self):
        task = ResetPasswordTaskPrototype.create(self.account)

        self.assertEqual(PostponedTaskPrototype._model_class.objects.all().count(), 0)
        self.assertEqual(ChangeCredentialsTaskPrototype._model_class.objects.all().count(), 0)

        self.check_html_ok(self.request_html(reverse('accounts:profile:reset-password-processed') + ('?task=%s' % task.uuid)))

        self.assertEqual(PostponedTaskPrototype._model_class.objects.all().count(), 1)
        self.assertEqual(ChangeCredentialsTaskPrototype._model_class.objects.all().count(), 1)

        self.assertEqual(django_authenticate(nick='test_user', password='******').id, self.account.id)
Example #11
0
    def test_reset_password_processed(self):
        task = ResetPasswordTaskPrototype.create(self.account)

        self.assertEqual(PostponedTaskPrototype._model_class.objects.all().count(), 0)
        self.assertEqual(ChangeCredentialsTaskPrototype._model_class.objects.all().count(), 0)

        self.check_html_ok(self.request_html(reverse('accounts:profile:reset-password-processed') + ('?task=%s' % task.uuid)))

        self.assertEqual(PostponedTaskPrototype._model_class.objects.all().count(), 1)
        self.assertEqual(ChangeCredentialsTaskPrototype._model_class.objects.all().count(), 1)

        self.assertEqual(django_authenticate(nick=self.account.nick, password='******').id, self.account.id)
Example #12
0
 def test_reset_password_already_processed(self):
     task = ResetPasswordTaskPrototype.create(self.account)
     self.check_html_ok(
         self.request_html(
             reverse('accounts:profile:reset-password-processed') +
             ('?task=%s' % task.uuid)))
     self.check_html_ok(
         self.request_html(
             reverse('accounts:profile:reset-password-processed') +
             ('?task=%s' % task.uuid)),
         texts=[
             'accounts.profile.reset_password_processed.already_processed'
         ])
Example #13
0
 def test_reset_password_expired(self):
     task = ResetPasswordTaskPrototype.create(self.account)
     with mock.patch(
             'the_tale.accounts.conf.accounts_settings.RESET_PASSWORD_TASK_LIVE_TIME',
             -1):
         self.check_html_ok(
             self.request_html(
                 reverse('accounts:profile:reset-password-processed') +
                 ('?task=%s' % task.uuid)),
             texts=[
                 'accounts.profile.reset_password_processed.time_expired'
             ])
     self.assertEqual(
         django_authenticate(nick=self.account.nick, password='******').id,
         self.account.id)
Example #14
0
 def test_reset_password_expired(self):
     task = ResetPasswordTaskPrototype.create(self.account)
     with mock.patch('the_tale.accounts.conf.accounts_settings.RESET_PASSWORD_TASK_LIVE_TIME', -1):
         self.check_html_ok(self.request_html(reverse('accounts:profile:reset-password-processed') + ('?task=%s' % task.uuid)),
                            texts=['accounts.profile.reset_password_processed.time_expired'])
     self.assertEqual(django_authenticate(nick='test_user', password='******').id, self.account.id)
Example #15
0
 def test_reset_password_already_processed(self):
     task = ResetPasswordTaskPrototype.create(self.account)
     self.check_html_ok(self.request_html(reverse('accounts:profile:reset-password-processed') + ('?task=%s' % task.uuid)))
     self.check_html_ok(self.request_html(reverse('accounts:profile:reset-password-processed') + ('?task=%s' % task.uuid)),
                        texts=['accounts.profile.reset_password_processed.already_processed'])