Translated using Weblate (Albanian)
[mailman-postorious.git] / src / postorius / tests / test_member_forms.py
blobd875eca656d8f69020d54da12ab778717fbd224f
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2012-2023 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):
25 def test_form_labels(self):
26 form = MemberForm({})
27 self.assertTrue('email' in form.fields.keys())
28 self.assertEqual(form.fields['email'].label, 'Email Address')
29 self.assertTrue('display_name' in form.fields.keys())
30 self.assertEqual(form.fields['display_name'].label, 'Display Name')
32 def test_form_errors(self):
33 form = MemberForm({})
34 self.assertFalse(form.is_valid())
35 self.assertEqual(
36 form.errors['email'][0], 'Please enter an email address.'
38 form = MemberForm({'email': 'invalid.example.com'})
39 self.assertFalse(form.is_valid())
40 self.assertEqual(
41 form.errors['email'][0], 'Please enter a valid email address.'