Beispiel #1
0
 def test_blank_data(self):
     form = EmergencyContactForm({})
     self.assertFalse(form.is_valid())
     self.assertEqual(
         form.errors, {
             'full_name': ['This field is required.'],
             'relationship': ['This field is required.'],
         })
Beispiel #2
0
 def test_submit_cancel_form_actions(self):
     """
     Test the existence of submit/cancel buttons
     """
     template = engines['django'].from_string("""
     {% load crispy_forms_tags %}
         {% crispy form %}
     """)
     form = EmergencyContactForm()
     context = {'form': form, 'cancel_button_path': 'trips:trip_list'}
     html = template.render(context)
     self.assertEqual(html.count('input type="submit"'), 1)
     self.assertEqual(html.count('name="cancel">Cancel</a>'), 1)
Beispiel #3
0
 def test_zip_code_field_label(self):
     form = EmergencyContactForm()
     self.assertEqual(form.fields['zip_code'].label, 'ZIP code')
Beispiel #4
0
 def test_street_address_line_2_field_label(self):
     form = EmergencyContactForm()
     self.assertEqual(form.fields['street_address_line2'].label,
                      'Address 2')
Beispiel #5
0
 def test_secondary_phone_field_label(self):
     form = EmergencyContactForm()
     self.assertEqual(form.fields['secondary_phone'].label,
                      'Phone (secondary)')
Beispiel #6
0
 def test_form_field_class(self):
     form = EmergencyContactForm()
     self.assertEqual(form.helper.field_class, 'col-md-9')
Beispiel #7
0
 def test_form_action(self):
     form = EmergencyContactForm()
     self.assertEqual(form.helper.form_action, '')
Beispiel #8
0
 def test_form_method(self):
     form = EmergencyContactForm()
     self.assertEqual(form.helper.form_method, 'post')
Beispiel #9
0
 def test_form_class(self):
     form = EmergencyContactForm()
     self.assertEqual(form.helper.form_class, 'account_info_forms')
Beispiel #10
0
 def test_form_id(self):
     form = EmergencyContactForm()
     self.assertEqual(form.helper.form_id, 'id-EmergencyContactForm')