Ejemplo n.º 1
0
 def test_date_range_interval_form_valid(self):
     form_data = {
         'interval': 'days',
         'start_date': '2017-12-18',
         'end_date': '2018-01-18'
     }
     form = dates.DateRangeIntervalForm(data=form_data)
     self.assertTrue(form.is_valid())
Ejemplo n.º 2
0
 def test_date_range_interval_form_end_date_future(self):
     end_date_in_advance = timezone.now() + datetime.timedelta(days=31)
     form_data = {
         'start_date': '2017-12-18',
         'end_date': end_date_in_advance.strftime(self.STR_DATE_FORMAT)
     }
     form = dates.DateRangeIntervalForm(data=form_data)
     self.assertRaises(forms.ValidationError)
     self.assertFalse(form.is_valid())
Ejemplo n.º 3
0
 def test_date_range_interval_form_start_date_after_end_date(self):
     start_date = timezone.now() + datetime.timedelta(days=31)
     end_date = timezone.now()
     form_data = {
         'start_date': start_date.strftime(self.STR_DATE_FORMAT),
         'end_date': end_date.strftime(self.STR_DATE_FORMAT)
     }
     form = dates.DateRangeIntervalForm(data=form_data)
     self.assertRaises(forms.ValidationError)
     self.assertFalse(form.is_valid())
Ejemplo n.º 4
0
 def test_date_range_interval_end_invalid(self):
     form_data = {'start_date': '2017-11-18', 'end_date': '2018-22-22'}
     form = dates.DateRangeIntervalForm(data=form_data)
     self.assertRaises(forms.ValidationError)
     self.assertFalse(form.is_valid())