Example #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.'],
         })
Example #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)
Example #3
0
 def test_zip_code_field_label(self):
     form = EmergencyContactForm()
     self.assertEqual(form.fields['zip_code'].label, 'ZIP code')
Example #4
0
 def test_street_address_line_2_field_label(self):
     form = EmergencyContactForm()
     self.assertEqual(form.fields['street_address_line2'].label,
                      'Address 2')
Example #5
0
 def test_secondary_phone_field_label(self):
     form = EmergencyContactForm()
     self.assertEqual(form.fields['secondary_phone'].label,
                      'Phone (secondary)')
Example #6
0
 def test_form_field_class(self):
     form = EmergencyContactForm()
     self.assertEqual(form.helper.field_class, 'col-md-9')
Example #7
0
 def test_form_action(self):
     form = EmergencyContactForm()
     self.assertEqual(form.helper.form_action, '')
Example #8
0
 def test_form_method(self):
     form = EmergencyContactForm()
     self.assertEqual(form.helper.form_method, 'post')
Example #9
0
 def test_form_class(self):
     form = EmergencyContactForm()
     self.assertEqual(form.helper.form_class, 'account_info_forms')
Example #10
0
 def test_form_id(self):
     form = EmergencyContactForm()
     self.assertEqual(form.helper.form_id, 'id-EmergencyContactForm')