def test_registration(self):
        """
        Registration creates a new inactive account and a new profile
        with activation key, populates the correct account data and
        sends an activation email.

        """
        resp = self.client.post(reverse('registration_register'),
                                data={'username': '******',
                                      'email': '*****@*****.**',
                                      'password1': 'secret',
                                      'password2': 'secret'})
        self.assertRedirects(resp, reverse('registration_complete'))

        new_user = UserModel().objects.get(username='******')

        self.failUnless(new_user.check_password('secret'))
        self.assertEqual(new_user.email, '*****@*****.**')

        # New user must not be active.
        self.failIf(new_user.is_active)

        # A registration profile was created, and an activation email
        # was sent.
        self.assertEqual(RegistrationProfile.objects.count(), 1)
        self.assertEqual(len(mail.outbox), 1)
Exemple #2
0
    def test_registration(self):
        """
        Registration creates a new account and logs the user in.

        """
        resp = self.client.post(reverse('registration_register'),
                                data={
                                    'username': '******',
                                    'email': '*****@*****.**',
                                    'password1': 'secret',
                                    'password2': 'secret'
                                })
        new_user = UserModel().objects.get(username='******')
        self.assertEqual(302, resp.status_code)
        self.failUnless(
            getattr(settings, 'SIMPLE_BACKEND_REDIRECT_URL', '/') in
            resp['Location'])

        self.failUnless(new_user.check_password('secret'))
        self.assertEqual(new_user.email, '*****@*****.**')

        # New user must be active.
        self.failUnless(new_user.is_active)

        # New user must be logged in.
        resp = self.client.get(reverse('registration_register'), follow=True)
        self.failUnless(resp.context['user'].is_authenticated)
Exemple #3
0
    def test_registration(self):
        """
        Registration creates a new inactive account and a new profile
        with activation key, populates the correct account data and
        sends an activation email.

        """
        resp = self.client.post(reverse('registration_register'),
                                data={
                                    'username': '******',
                                    'email': '*****@*****.**',
                                    'password1': 'secret',
                                    'password2': 'secret'
                                })
        self.assertRedirects(resp, reverse('registration_complete'))

        new_user = UserModel().objects.get(username='******')

        self.failUnless(new_user.check_password('secret'))
        self.assertEqual(new_user.email, '*****@*****.**')

        # New user must not be active.
        self.failIf(new_user.is_active)

        # A registration profile was created, and an activation email
        # was sent.
        self.assertEqual(self.registration_profile.objects.count(), 1)
        self.assertEqual(len(mail.outbox), 1)
    def test_registration_no_sites(self):
        """
        Registration still functions properly when
        ``django.contrib.sites`` is not installed; the fallback will
        be a ``RequestSite`` instance.

        """
        Site._meta.installed = False

        resp = self.client.post(reverse('registration_register'),
                                data={'username': '******',
                                      'email': '*****@*****.**',
                                      'password1': 'secret',
                                      'password2': 'secret'})
        self.assertEqual(302, resp.status_code)

        new_user = UserModel().objects.get(username='******')

        self.failUnless(new_user.check_password('secret'))
        self.assertEqual(new_user.email, '*****@*****.**')

        self.failIf(new_user.is_active)

        self.assertEqual(RegistrationProfile.objects.count(), 1)
        self.assertEqual(len(mail.outbox), 1)

        Site._meta.installed = True
Exemple #5
0
    def test_registration_no_sites(self):
        """
        Registration still functions properly when
        ``django.contrib.sites`` is not installed; the fallback will
        be a ``RequestSite`` instance.

        """
        resp = self.client.post(reverse('registration_register'),
                                data={
                                    'username': '******',
                                    'email': '*****@*****.**',
                                    'password1': 'secret',
                                    'password2': 'secret'
                                })
        self.assertEqual(302, resp.status_code)

        new_user = UserModel().objects.get(username='******')

        self.failUnless(new_user.check_password('secret'))
        self.assertEqual(new_user.email, '*****@*****.**')

        self.failIf(new_user.is_active)

        self.assertEqual(self.registration_profile.objects.count(), 1)
        self.assertEqual(len(mail.outbox), 1)
Exemple #6
0
    def test_registration(self):
        """
        Registration creates a new inactive account and a new profile
        with activation key, populates the correct account data and
        sends an activation email.

        """
        resp = self.client.post(
            reverse("registration_register"),
            data={"username": "******", "email": "*****@*****.**", "password1": "secret", "password2": "secret"},
        )
        self.assertRedirects(resp, reverse("registration_complete"))

        new_user = UserModel().objects.get(username="******")

        self.failUnless(new_user.check_password("secret"))
        self.assertEqual(new_user.email, "*****@*****.**")

        # New user must not be active.
        self.failIf(new_user.is_active)

        # A registration profile was created, and an activation email
        # was sent.
        self.assertEqual(RegistrationProfile.objects.count(), 1)
        self.assertEqual(len(mail.outbox), 1)
    def test_profile_retrieval(self):
        # Testing User Information Retrieval for Login
        new_user = UserModel().objects.create_user(**self.user_info)
        existing_user = UserModel().objects.get(username='******')

        self.failUnless(existing_user.check_password('letstravel'))
        self.assertEqual(existing_user.email, '*****@*****.**')
        self.failUnless(existing_user.is_active)
    def test_profile_retrieval(self):
        # Testing User Information Retrieval for Login
        new_user = UserModel().objects.create_user(**self.user_info)
        existing_user = UserModel().objects.get(username='******')

        self.failUnless(existing_user.check_password('letstravel'))
        self.assertEqual(existing_user.email, '*****@*****.**')
        self.failUnless(existing_user.is_active)
Exemple #9
0
    def test_registration_no_sites(self):
        """
        Registration still functions properly when
        ``django.contrib.sites`` is not installed; the fallback will
        be a ``RequestSite`` instance.

        """
        resp = self.client.post(
            reverse("registration_register"),
            data={"username": "******", "email": "*****@*****.**", "password1": "secret", "password2": "secret"},
        )
        self.assertEqual(302, resp.status_code)

        new_user = UserModel().objects.get(username="******")

        self.failUnless(new_user.check_password("secret"))
        self.assertEqual(new_user.email, "*****@*****.**")

        self.failIf(new_user.is_active)

        self.assertEqual(RegistrationProfile.objects.count(), 1)
        self.assertEqual(len(mail.outbox), 1)
    def test_registration(self):
        """
        Registration creates a new account and logs the user in.

        """
        resp = self.client.post(reverse('registration_register'),
                                data={'username': '******',
                                      'email': '*****@*****.**',
                                      'password1': 'secret',
                                      'password2': 'secret'})
        new_user = UserModel().objects.get(username='******')
        self.assertEqual(302, resp.status_code)
        self.failUnless(reverse('registration_complete') in resp['Location'])

        self.failUnless(new_user.check_password('secret'))
        self.assertEqual(new_user.email, '*****@*****.**')

        # New user must be active.
        self.failUnless(new_user.is_active)

        # New user must be logged in.
        resp = self.client.get(reverse('registration_register'))
        self.failUnless(resp.context['user'].is_authenticated())
    def test_registration(self):
        """
        Registration creates a new account and logs the user in.

        """
        resp = self.client.post(reverse('registration_register'),
                                data={'username': '******',
                                      'email': '*****@*****.**',
                                      'password1': 'secret',
                                      'password2': 'secret'})
        new_user = UserModel().objects.get(username='******')
        self.assertEqual(302, resp.status_code)
        self.assertIn(getattr(settings, 'SIMPLE_BACKEND_REDIRECT_URL', '/'),
                      resp['Location'])

        self.assertTrue(new_user.check_password('secret'))
        self.assertEqual(new_user.email, '*****@*****.**')

        # New user must be active.
        self.assertTrue(new_user.is_active)

        # New user must be logged in.
        resp = self.client.get(reverse('registration_register'), follow=True)
        self.assertTrue(resp.context['user'].is_authenticated)