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)
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
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
):
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
):
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.')