Exemplo n.º 1
0
 def test_invalid_date(self):
     data = {
         'description': u'',
         'title': u'',
         'title_not_announced': u'1',
         'location': u'',
         'department_suggest': u'',
         'start': u'94872394',
         'topics': u'',
         'speaker_suggest': u'',
         'location_suggest': u'',
         'department_organiser': u'',
         'speakers': u'',
         'booking_type': u'nr',
         'audience': u'public',
         'topic_suggest': u'',
         'status': models.EVENT_IN_PREPARATION,
         'end': VALID_DATE_STRING,
     }
     form = forms.EventForm(data)
     self.assertEquals(form.is_valid(), False, "blanked form should not validate")
     errors = form.errors.as_data()
     logging.info("form errors: %s", errors)
     self.assertIn('start', errors)
     self.assertEquals(len(errors), 1)
Exemplo n.º 2
0
 def test_all_fields_blanked(self):
     data = {
         'description': u'',
         'title': u'',
         'location': u'',
         'department_suggest': u'',
         'start': u'',
         'topics': u'',
         'speaker_suggest': u'',
         'location_suggest': u'',
         'department_organiser': u'',
         'speakers': u'',
         'topic_suggest': u'',
         'end': u'',
     }
     form = forms.EventForm(data)
     self.assertEquals(form.is_valid(), False, "blanked form should not validate")
     errors = form.errors.as_data()
     logging.info("form errors: %s", errors)
     self.assertEquals(len(errors), 5)
     self.assertIn('booking_type', errors)
     self.assertIn('status', errors)
     self.assertIn('start', errors)
     self.assertIn('end', errors)
     self.assertIn('__all__', errors)
Exemplo n.º 3
0
 def test_empty(self):
     form = forms.EventForm({})
     self.assertEquals(form.is_valid(), False, "empty form should not validate")
     errors = form.errors.as_data()
     logging.info("form errors: %s", errors)
     self.assertEquals(len(errors), 5)
     self.assertIn('booking_type', errors)
     self.assertIn('start', errors)
     self.assertIn('end', errors)
     self.assertIn('status', errors)
     self.assertIn('__all__', errors)
Exemplo n.º 4
0
 def test_title_not_announced_true_title_blank(self):
     data = {
         'title': '',
         'title_not_announced': 'true',
     }
     form = forms.EventForm(data)
     errors = form.errors.as_data()
     logging.info("form errors: %s", errors)
     self.assertNotIn("Either provide the Title or mark it as TBA", form.errors.get('__all__', []))
     self.assertNotIn('title', form.errors)
     self.assertNotIn('title_not_announced', form.errors)
Exemplo n.º 5
0
 def test_happy(self):
     data = {
         'description': u'',
         'title': u'',
         'title_not_announced': u'1',
         'location': u'',
         'department_suggest': u'',
         'start': VALID_DATE_STRING,
         'topics': u'',
         'speaker_suggest': u'',
         'location_suggest': u'',
         'department_organiser': u'',
         'speakers': u'',
         'booking_type': u'nr',
         'audience': u'public',
         'topic_suggest': u'',
         'status': models.EVENT_IN_PREPARATION,
         'end': VALID_DATE_STRING,
     }
     form = forms.EventForm(data)
     errors = form.errors.as_data()
     logging.info("form errors: %s", errors)
     self.assertTrue(form.is_valid(), "form should validate")