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 %} """) kwargs = {'choices': (('fake', 'fake'), ), 'location_type': 'fake'} form = LocationForm(**kwargs) context = { 'form': form, 'cancel_button_path': 'trips:trip_detail', 'trip_id': self.trip.id } html = template.render(context) self.assertEqual(html.count('input type="submit"'), 1) self.assertEqual(html.count('name="cancel">Cancel</a>'), 1)
def test_form_method(self): kwargs = {'choices': 'fake', 'location_type': 'fake'} form = LocationForm(**kwargs) self.assertEqual(form.helper.form_method, 'post')
def test_form_class(self): kwargs = {'choices': 'fake', 'location_type': 'fake'} form = LocationForm(**kwargs) self.assertEqual(form.helper.form_class, 'trip_forms')
def test_longitude_field_label(self): kwargs = {'choices': 'fake', 'location_type': 'fake'} form = LocationForm(**kwargs) self.assertEqual(form.fields['longitude'].label, 'Longitude')
def test_date_field_label(self): kwargs = {'choices': 'fake', 'location_type': 'fake'} form = LocationForm(**kwargs) self.assertEqual(form.fields['date'].label, None)
def test_title_field_label(self): kwargs = {'choices': 'fake', 'location_type': 'fake'} form = LocationForm(**kwargs) self.assertEqual(form.fields['title'].label, 'Title for Trip Plan')
def test_form_action(self): kwargs = {'choices': 'fake', 'location_type': 'fake'} form = LocationForm(**kwargs) self.assertEqual(form.helper.form_action, '')