Merge lp://staging/~godricglow/postorius/tests_forms into lp://staging/postorius

Proposed by Pranjal Yadav
Status: Needs review
Proposed branch: lp://staging/~godricglow/postorius/tests_forms
Merge into: lp://staging/postorius
Diff against target: 196 lines (+90/-25)
3 files modified
src/postorius/forms.py (+20/-10)
src/postorius/tests/__init__.py (+0/-1)
src/postorius/tests/test_forms.py (+70/-14)
To merge this branch: bzr merge lp://staging/~godricglow/postorius/tests_forms
Reviewer Review Type Date Requested Status
Florian Fuchs Pending
Review via email: mp+251740@code.staging.launchpad.net

Description of the change

Added tests for forms.py. Improving overall coverage

To post a comment you must log in.
Revision history for this message
Florian Fuchs (flo-fuchs) wrote :

Hi Pranjal,

thanks for this merge proposal. It looks pretty good so far, I only have some minor comments (see below).

Florian

Revision history for this message
Pranjal Yadav (godricglow) wrote :
Download full text (9.2 KiB)

Hi Florian

Thanks for you reply, I checked all you comments carefully and have replied
below.

On Tue, Mar 10, 2015 at 2:43 PM, Florian Fuchs <email address hidden> wrote:

> Hi Pranjal,
>
> thanks for this merge proposal. It looks pretty good so far, I only have
> some minor comments (see below).
>
> Florian
>
> Diff comments:
>
> > === modified file 'src/postorius/forms.py'
> > --- src/postorius/forms.py 2015-02-09 14:35:44 +0000
> > +++ src/postorius/forms.py 2015-03-04 13:56:28 +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,20 @@
> > 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):
> > +
> > + cleaned_data = super(ListNew, self).clean()
> > + listname = cleaned_data.get('listname')
>
> For a single field's clean method, we don't need to call the parent's
> clean method. We can just access `self.cleaned_data.get('listname')`
> directly.
>

Good point but I already tried doing that, it seems __init__ method creates
some problem otherwise when I don't call the parent's clean method. I
talked to abhilash and he too said that cleaning through parent seems to
work. I need your advice on this part.

>
> > try:
> > - validate_email(self.cleaned_data['listname'] + '@
> example.net')
> > + validate_slug(listname)
>
> I think `validate_slug` is too restrictive here, because the local part of
> an email address has more valid characters than validate_slug allows.
>

> I guess there is some confusion here, I'm validating the email with
> 'validate_email' only. I'm using validate_slug for listname only and I
> think listname need to have that restriction which again is not my decision
> but my choice as per sample data from various tests, Please tell me If I
> need to do otherwise.
> > except:
> > ...

Read more...

Unmerged revisions

204. By Pranjal Yadav <email address hidden>

Adding new tests for forms.py

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches