Exemple #1
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 %}
     """)
     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)
Exemple #2
0
 def test_form_method(self):
     kwargs = {'choices': 'fake', 'location_type': 'fake'}
     form = LocationForm(**kwargs)
     self.assertEqual(form.helper.form_method, 'post')
Exemple #3
0
 def test_form_class(self):
     kwargs = {'choices': 'fake', 'location_type': 'fake'}
     form = LocationForm(**kwargs)
     self.assertEqual(form.helper.form_class, 'trip_forms')
Exemple #4
0
 def test_longitude_field_label(self):
     kwargs = {'choices': 'fake', 'location_type': 'fake'}
     form = LocationForm(**kwargs)
     self.assertEqual(form.fields['longitude'].label, 'Longitude')
Exemple #5
0
 def test_date_field_label(self):
     kwargs = {'choices': 'fake', 'location_type': 'fake'}
     form = LocationForm(**kwargs)
     self.assertEqual(form.fields['date'].label, None)
Exemple #6
0
 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')
Exemple #7
0
 def test_form_action(self):
     kwargs = {'choices': 'fake', 'location_type': 'fake'}
     form = LocationForm(**kwargs)
     self.assertEqual(form.helper.form_action, '')