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