Commits

offline committed 01bf670

all test now pass

Comments (0)

Files changed (5)

openauth/forms.py

     To provide custom registration form, please refer to settings 
     file for instractions.
     """
-    if openauth.settings.DISPLAYNAME_REQUIRED:
-        username = forms.CharField()
+    def __init__(self, *args, **kwargs):
+        if openauth.settings.DISPLAYNAME_REQUIRED:
+            self.base_fields['username'] = forms.CharField()
+        super(RegistrationForm, self).__init__(*args, **kwargs)
+
     login = LoginField()
     password = PasswordField(label=_('Password'))
     password_dup = PasswordField(label=_('Password (confirmation)'))

openauth/templates/404.html

+{% extends "base.html" %}

openauth/tests/settings.py

 DEBUG = True
 DATABASE_ENGINE = 'sqlite3'
 
-ROOT_URLCONF = 'openauth.urls'
+ROOT_URLCONF = 'openauth.tests.urls'
 
 INSTALLED_APPS = (
     'django.contrib.admin',

openauth/tests/tests.py

 
     def setUp(self):
         openauth.settings.REGISTRATION_ALLOWED = True
-        openauth.settings.USERNAME_REGEX = USER_REGEX
+        openauth.settings.DISPLAYNAME_REQUIRED = True
+        openauth.settings.LOGIN_REGEX = EMAIL_REGEX
+        openauth.settings.AUTHENTICATION_TYPES = ['email']
         openauth.settings.REGISTRATION_FORM = "openauth.forms.RegistrationForm"
         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'}) 
+        response = self.client.post(self.registration_url, {'username': 'petya', 'login': 'admin@example.com', 'password': 'test', 'password_dup': 'test'}) 
         user = User.objects.get(email='admin@example.com')
         self.failUnlessEqual(user.username, 'petya')
 
         notify.settings.NOTIFY_TYPE = 'flashcookie'
         openauth.settings.REGISTRATION_ALLOWED = True
         openauth.settings.ACTIVATION_REQUIRED = True
-        openauth.settings.USERNAME_REGEX = USER_REGEX
+        openauth.settings.LOGIN_REDIRECT_URL = "/auth/user/"
+        openauth.settings.LOGIN_REGEX = USER_REGEX
         openauth.settings.AUTHENTICATION_TYPES = ['username']
         self.client = Client()
         self.login_url = reverse('openauth-login')
         self.active_user = User.objects.create_user('ivan', 'ivan@example.com', password='test')
+        self.active_user.is_active = True
+        self.active_user.save()
         self.inactive_user = User.objects.create_user('vova', 'vova@example.com', password='test')
         self.inactive_user.is_active = False
         self.inactive_user.save()
         self.inactive_user.delete()
 
     def test_valid_active_user_activation_enabled(self):
-        response = self.client.post(self.login_url, {'username': self.active_user.username, 'password': 'test'})
+        response = self.client.post(self.login_url, {'login': self.active_user.username, 'password': 'test'})
         self.assertRedirects(response, openauth.settings.LOGIN_REDIRECT_URL)
 
     def test_invalid_active_user_activation_enabled(self):
-        response = self.client.post(self.login_url, {'username': self.active_user.username, 'password': 'INCORRECT'})
+        response = self.client.post(self.login_url, {'login': self.active_user.username, 'password': 'INCORRECT'})
         self.assertEqual(response.status_code, 200) #not redirect to LOGIN_REDIRECT_URL
 
     def test_inactive_user_activation_enabled(self):
-        response = self.client.post(self.login_url, {'username': self.inactive_user.username, 'password': 'test'})
+        response = self.client.post(self.login_url, {'login': self.inactive_user.username, 'password': 'test'})
         self.assertEqual(response.status_code, 200)
 
     def test_inactive_user_activation_disabled(self):
         openauth.settings.ACTIVATION_REQUIRED = False
-        response = self.client.post(self.login_url, {'username': self.inactive_user.username, 'password': 'test'})
+        response = self.client.post(self.login_url, {'login': self.inactive_user.username, 'password': 'test'})
         self.assertRedirects(response, openauth.settings.LOGIN_REDIRECT_URL)

openauth/tests/urls.py

+from django.conf.urls.defaults import *
+
+urlpatterns = patterns('',
+    (r'', include('confirmation.urls')),
+    (r'^auth/', include('openauth.urls')),
+)
+