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