Commits

James Bennett committed 4ef31f0

Test that we properly redirect when registration is closed.

  • Participants
  • Parent commits 272655b

Comments (0)

Files changed (1)

File registration/tests.py

         self.assertEqual(response['Location'], 'http://testserver%s' % reverse('registration_complete'))
         self.assertEqual(len(mail.outbox), 1)
 
+        # Invalid data can't register.
+        response = self.client.post(reverse('registration_register'),
+                                    data={ 'username': 'bob',
+                                           'email': 'bobe@example.com',
+                                           'password1': 'foo',
+                                           'password2': 'bar' })
+        self.assertEqual(response.status_code, 200)
+        self.assertEqual(len(mail.outbox), 1)
+
+        old_allowed = getattr(settings, 'REGISTRATION_OPEN', True)
+        settings.REGISTRATION_OPEN = False
+
+        response = self.client.get(reverse('registration_register'))
+        self.assertEqual(response.status_code, 302)
+        self.assertEqual(response['Location'], 'http://testserver%s' % reverse('registration_disallowed'))
+
+        settings.REGISTRATION_OPEN = old_allowed
+
+
     def test_activation_view(self):
         """
         Call the ``activate`` view and ensure that it properly