コード例 #1
0
ファイル: backends.py プロジェクト: fahdoo/portfolio
    def test_activation_action(self):
        """
        Test manual activation of users view admin action.
        
        """
        admin_class = RegistrationAdmin(RegistrationProfile, admin.site)

        alice = self.backend.register(
            _mock_request(), username="******", email="*****@*****.**", password1="swordfish"
        )

        admin_class.activate_users(_mock_request(), RegistrationProfile.objects.all())
        self.failUnless(User.objects.get(username="******").is_active)
コード例 #2
0
ファイル: backends.py プロジェクト: fahdoo/portfolio
    def test_email_send_action(self):
        """
        Test re-sending of activation emails via admin action.
        
        """
        admin_class = RegistrationAdmin(RegistrationProfile, admin.site)

        alice = self.backend.register(
            _mock_request(), username="******", email="*****@*****.**", password1="swordfish"
        )

        admin_class.resend_activation_email(_mock_request(), RegistrationProfile.objects.all())
        self.assertEqual(len(mail.outbox), 2)  # One on registering, one more on the resend.

        RegistrationProfile.objects.filter(user=alice).update(activation_key=RegistrationProfile.ACTIVATED)
        admin_class.resend_activation_email(_mock_request(), RegistrationProfile.objects.all())
        self.assertEqual(len(mail.outbox), 2)  # No additional email because the account has activated.