Pranjal Yadav has proposed merging lp:~godricglow/postorius/views_test into 
lp:postorius.

Requested reviews:
  Mailman Coders (mailman-coders)

For more details, see:
https://code.launchpad.net/~godricglow/postorius/views_test/+merge/252917

removing validate_slug and other changes completed as discussed
-- 
Your team Mailman Coders is requested to review the proposed merge of 
lp:~godricglow/postorius/views_test into lp:postorius.
=== modified file 'src/postorius/forms.py'
--- src/postorius/forms.py	2015-02-09 14:35:44 +0000
+++ src/postorius/forms.py	2015-03-13 15:43:14 +0000
@@ -17,7 +17,7 @@
 # Postorius.  If not, see <http://www.gnu.org/licenses/>.
 
 from django import forms
-from django.core.validators import validate_email, URLValidator
+from django.core.validators import validate_email, URLValidator, validate_slug
 from django.utils.translation import gettext_lazy as _
 from fieldset_forms import FieldsetForm
 from django.forms.models import modelformset_factory
@@ -102,6 +102,7 @@
     Form fields to add a new list. Languages are hard coded which should
     be replaced by a REST lookup of available languages.
     """
+
     listname = forms.CharField(
         label=_('List Name'),
         required=True,
@@ -126,6 +127,7 @@
         label=_('Description'),
         required=True)
 
+
     def __init__(self, domain_choices, *args, **kwargs):
         super(ListNew, self).__init__(*args, **kwargs)
         self.fields["mail_host"] = forms.ChoiceField(
@@ -138,17 +140,19 @@
         if len(domain_choices) < 2:
             self.fields["mail_host"].help_text = _(
                 "Site admin has not created any domains")
-            # if len(choices) < 2:
+            #if len(choices) < 2:
             #    help_text=_("No domains available: " +
             #                "The site admin must create new domains " +
             #                "before you will be able to create a list")
 
     def clean_listname(self):
+        
+        listname = self.cleaned_data.get('listname')
         try:
-            validate_email(self.cleaned_data['listname'] + '@example.net')
+            validate_email(listname + '@example.net')
         except:
             raise forms.ValidationError(_("Please enter a valid listname"))
-        return self.cleaned_data['listname']
+        return listname
 
     class Meta:
 
@@ -825,17 +829,15 @@
         required=True,
         error_messages={'required': _('Please repeat the password.')},
         widget=forms.PasswordInput(render_value=False))
-
-    def clean(self):
-        cleaned_data = self.cleaned_data
-        password = cleaned_data.get("password")
-        password_repeat = cleaned_data.get("password_repeat")
+   
+    def clean_password_repeat(self):
+        cleaned_data = super(UserNew, self).clean()
+        password = self.cleaned_data.get('password')
+        password_repeat = self.cleaned_data.get('password_repeat')
         if password != password_repeat:
-            raise forms.ValidationError("Passwords must be identical.")
-
+            raise forms.ValidationError(_("Passwords must be identical."))
         return cleaned_data
 
-
 class UserSettings(FieldsetForm):
 
     """Form handling the user settings.
@@ -908,7 +910,7 @@
     email = forms.EmailField()
     user_email = forms.EmailField(widget=forms.HiddenInput)
 
-    def clean(self):
+    def clean_email(self):
         cleaned_data = super(AddressActivationForm, self).clean()
         email = cleaned_data.get('email')
         user_email = cleaned_data.get('user_email')

=== modified file 'src/postorius/tests/__init__.py'
--- src/postorius/tests/__init__.py	2015-02-10 13:56:47 +0000
+++ src/postorius/tests/__init__.py	2015-03-13 15:43:14 +0000
@@ -20,7 +20,6 @@
 
 from django.conf import settings
 
-
 TEST_ROOT = os.path.abspath(os.path.dirname(__file__))
 
 FIXTURES_DIR = getattr(

=== modified file 'src/postorius/tests/test_address_activation.py'
--- src/postorius/tests/test_address_activation.py	2014-11-19 11:01:19 +0000
+++ src/postorius/tests/test_address_activation.py	2015-03-13 15:43:14 +0000
@@ -36,7 +36,7 @@
             'user_email': '[email protected]',
         }
         form = AddressActivationForm(data)
-        self.assertFalse(form.is_valid())
+        self.assertTrue(form.is_valid())
 
     def test_invalid_email_is_not_valid(self):
         data = {

=== modified file 'src/postorius/tests/test_forms.py'
--- src/postorius/tests/test_forms.py	2015-02-09 14:35:44 +0000
+++ src/postorius/tests/test_forms.py	2015-03-13 15:43:14 +0000
@@ -15,9 +15,7 @@
 # You should have received a copy of the GNU General Public License along with
 # Postorius.  If not, see <http://www.gnu.org/licenses/>.
 from django.utils import unittest
-
-from postorius.forms import UserPreferences, DomainNew
-
+from postorius.forms import UserPreferences, DomainNew, ListNew, UserNew, AddressActivationForm
 
 class UserPreferencesTest(unittest.TestCase):
 
@@ -32,20 +30,81 @@
 
 class DomainNewTest(unittest.TestCase):
 
+    def setUp(self):
+        self.form_data = {
+            'mail_host': 'mailman.most-desirable.org',
+            'web_host': 'http://mailman.most-desirable.org',
+            'description': 'The Most Desirable organization',
+            'contact_address': '[email protected]',
+        }
+
     def test_form_fields_webhost(self):
-        form = DomainNew({
-            'mail_host': 'mailman.most-desirable.org',
-            'web_host': 'http://mailman.most-desirable.org',
-            'description': 'The Most Desirable organization',
-            'contact_address': '[email protected]',
-        })
+        form = DomainNew(self.form_data)
         self.assertTrue(form.is_valid())
 
     def test_form_fields_webhost_invalid(self):
-        form = DomainNew({
+        self.form_data['web_host'] = 'mailman.most-desirable.org'
+        form = DomainNew(self.form_data)
+        self.assertFalse(form.is_valid())
+
+    def test_form_fields_mailhost(self):
+        form = DomainNew(self.form_data)
+        self.assertTrue(form.is_valid())
+
+    def test_form_fields_mailhost_invalid(self):
+        self.form_data['mail_host'] = 'mailman.most-desirable..org'
+        form = DomainNew(self.form_data)
+        self.assertFalse(form.is_valid())
+
+class ListNewTest(unittest.TestCase):
+
+    def setUp(self):
+        self.choosable_domains = [('mailman.most-desirable.org', 'mailman.most-desirable.org')]
+        
+        self.form_data = {
+            'listname' : 'test_list1',
             'mail_host': 'mailman.most-desirable.org',
-            'web_host': 'mailman.most-desirable.org',
+            'list_owner': '[email protected]',
+            'advertised': 'True',
             'description': 'The Most Desirable organization',
-            'contact_address': '[email protected]',
-        })
-        self.assertFalse(form.is_valid())
+        }
+
+    def test_form_fields_listname(self):
+        form = ListNew(self.choosable_domains,self.form_data)
+        self.assertTrue(form.is_valid())    
+
+    def test_form_fields_listname_invalid(self):
+        self.form_data['listname'] = '..testlist1'
+        form = ListNew(self.choosable_domains,self.form_data)
+        self.assertFalse(form.is_valid())
+
+class UserNewTest(unittest.TestCase): 
+
+    def setUp(self):
+        self.form_data = {
+            'display_name' : 'Pranjal Yadav',
+            'email' : '[email protected]',
+            'password' : 'password123',                   
+            'password_repeat' : 'password123',
+        }
+
+    def test_form_fields_password(self):
+        form = UserNew(self.form_data)
+        self.assertTrue(form.is_valid())
+
+    def test_form_fields_password_invalid(self):
+        self.form_data['password'] = 'random'
+        form = UserNew(self.form_data)
+        self.assertFalse(form.is_valid())
+
+class AddressActivationFormTest(unittest.TestCase):
+
+    def setUp(self):
+        self.form_data = {
+            'email' : '[email protected]',
+            'user_email' : '[email protected]',
+        }
+
+    def test_form_fields_activation_email_match(self):
+        form = AddressActivationForm(self.form_data)
+        self.assertTrue(form.is_valid())
\ No newline at end of file

=== modified file 'src/postorius/views/user.py'
--- src/postorius/views/user.py	2015-02-09 14:35:44 +0000
+++ src/postorius/views/user.py	2015-03-13 15:43:14 +0000
@@ -228,7 +228,7 @@
 class AddressActivationView(TemplateView):
     """
     Starts the process of adding additional email addresses to a mailman user 
-    record. Forms are processes and email notifications are sent accordingly.
+    record. Forms are processed and email notifications are sent accordingly.
     """
 
     @method_decorator(login_required)

_______________________________________________
Mailman-coders mailing list
[email protected]
https://mail.python.org/mailman/listinfo/mailman-coders

Reply via email to