Prepare for 1.3.3 release.
[mailman-postorious.git] / src / postorius / tests / test_member_forms.py
blob203bcc550995a99a9c235a680ce8963e745e7b75
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2012-2019 by the Free Software Foundation, Inc.
4 # This file is part of Postorius.
6 # Postorius is free software: you can redistribute it and/or modify it under
7 # the terms of the GNU General Public License as published by the Free
8 # Software Foundation, either version 3 of the License, or (at your option)
9 # any later version.
10 # Postorius is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 # more details.
15 # You should have received a copy of the GNU General Public License along with
16 # Postorius. If not, see <http://www.gnu.org/licenses/>.
19 from django.test import TestCase
21 from postorius.forms import MemberForm
24 class TestMemberForm(TestCase):
26 def test_form_labels(self):
27 form = MemberForm({})
28 self.assertTrue('email' in form.fields.keys())
29 self.assertEqual(form.fields['email'].label, 'Email Address')
30 self.assertTrue('display_name' in form.fields.keys())
31 self.assertEqual(form.fields['display_name'].label, 'Display Name')
33 def test_form_errors(self):
34 form = MemberForm({})
35 self.assertFalse(form.is_valid())
36 self.assertEqual(form.errors['email'][0],
37 'Please enter an email address.')
38 form = MemberForm({'email': 'invalid.example.com'})
39 self.assertFalse(form.is_valid())
40 self.assertEqual(form.errors['email'][0],
41 'Please enter a valid email address.')