cof.tests -- Really check initial of built form

This commit is contained in:
Aurélien Delobelle 2018-09-30 12:56:36 +02:00
parent 7512454825
commit 44e5387f15

View file

@ -217,9 +217,6 @@ class RegistrationFormViewTests(ViewTestCaseMixin, TestCase):
auth_user = 'staff'
auth_forbidden = [None, 'user', 'member']
def get_initial(self, form, name):
return form.get_initial_for_field(form.fields[name], name)
def test_empty(self):
r = self.client.get(self.t_urls[0])
@ -241,9 +238,9 @@ class RegistrationFormViewTests(ViewTestCaseMixin, TestCase):
events_form = r.context['event_formset']
clubs_form = r.context['clubs_form']
self.assertEqual(self.get_initial(user_form, 'username'), 'user')
self.assertEqual(self.get_initial(user_form, 'first_name'), 'first')
self.assertEqual(self.get_initial(user_form, 'last_name'), 'last')
self.assertEqual(user_form['username'].initial, 'user')
self.assertEqual(user_form['first_name'].initial, 'first')
self.assertEqual(user_form['last_name'].initial, 'last')
def test_clipper(self):
r = self.client.get(self.t_urls[2])
@ -253,13 +250,10 @@ class RegistrationFormViewTests(ViewTestCaseMixin, TestCase):
events_form = r.context['event_formset']
clubs_form = r.context['clubs_form']
self.assertEqual(self.get_initial(user_form, 'first_name'), 'First')
self.assertEqual(
self.get_initial(user_form, 'last_name'), 'Last1 Last2')
self.assertEqual(
self.get_initial(user_form, 'email'), 'uid@clipper.ens.fr')
self.assertEqual(
self.get_initial(profile_form, 'login_clipper'), 'uid')
self.assertEqual(user_form['first_name'].initial, 'First')
self.assertEqual(user_form['last_name'].initial, 'Last1 Last2')
self.assertEqual(user_form['email'].initial, 'uid@clipper.ens.fr')
self.assertEqual(profile_form['login_clipper'].initial, 'uid')
@override_settings(LDAP_SERVER_URL='ldap_url')