Commits

offline committed 9b0014d

registration test implementation started

Comments (0)

Files changed (1)

openauth/tests.py

+import unittest
+
+from django.core.urlresolvers import reverse
+from django.contrib.auth.models import User
+from django.test.client import Client
+
+import openauth
+from openauth.models import Profile
+from openauth import views
+
+
+class RegistrationTest(unittest.TestCase):
+    
+    def setUp(self):
+        openauth.settings.REGISTRATION_ALLOWED = True
+        self.client = Client()
+        self.registration_url = reverse('openauth-registration')
+
+    def test_registration(self):
+        response = self.client.post(self.registration_url, {'username': 'petya', 'email': 'admin@example.com', 'password': 'test', 'password_dup': 'test'}) 
+        user = User.objects.get(email='admin@example.com')
+        self.failUnlessEqual(user.username, 'petya')
+
+    def test_disabled_registration(self):
+        openauth.settings.REGISTRATION_ALLOWED = False
+        response = self.client.post(self.registration_url, {'username': 'petya', 'email': 'admin@example.com', 'password': 'test', 'password_dup': 'test'}) 
+        self.failUnlessRaises(User.DoesNotExist, User.objects.get, pk=1)
+
+