Esempio n. 1
0
 def test_end_before_start(self):
     startdate = datetime(2015, 2, 1)
     enddate = datetime(2015, 1, 1)
     datespan = DateSpan(startdate, enddate)
     self.assertFalse(datespan.is_valid())
     self.assertEqual(datespan.get_validation_reason(),
                      "You can't have an end date of %s after start date of %s" % (enddate, startdate))
Esempio n. 2
0
 def test_end_before_start(self):
     startdate = datetime(2015, 02, 01)
     enddate = datetime(2015, 01, 01)
     datespan = DateSpan(startdate, enddate)
     self.assertFalse(datespan.is_valid())
     self.assertEqual(datespan.get_validation_reason(),
                      "You can't have an end date of %s after start date of %s" % (enddate, startdate))
Esempio n. 3
0
 def test_datespan_too_long(self):
     datespan = DateSpan(datetime(2015, 1, 1),
                         datetime(2015, 7, 1),
                         max_days=90)
     self.assertFalse(datespan.is_valid())
     self.assertEqual(
         datespan.get_validation_reason(),
         "You are limited to a span of 90 days, but this date range spans 181 days"
     )
Esempio n. 4
0
 def test_datespan_ok(self):
     datespan = DateSpan(datetime(2015, 1, 1), datetime(2015, 4, 1), max_days=90)
     self.assertTrue(datespan.is_valid())
Esempio n. 5
0
 def test_wrong_century(self):
     datespan = DateSpan(datetime(1815, 1, 1), datetime(1815, 2, 1))
     self.assertFalse(datespan.is_valid())
     self.assertEqual(datespan.get_validation_reason(), "You can't use dates earlier than the year 1900")
Esempio n. 6
0
 def test_date_missing(self):
     datespan = DateSpan(datetime(2015, 1, 1), None)
     self.assertFalse(datespan.is_valid())
     self.assertEqual(datespan.get_validation_reason(), "You have to specify both dates!")
Esempio n. 7
0
 def test_ok(self):
     datespan = DateSpan(datetime(2015, 1, 1), datetime(2015, 2, 1))
     self.assertTrue(datespan.is_valid())
     self.assertEqual(datespan.get_validation_reason(), "")
Esempio n. 8
0
 def test_datespan_too_long(self):
     datespan = DateSpan(datetime(2015, 01, 01), datetime(2015, 07, 01), max_days=90)
     self.assertFalse(datespan.is_valid())
     self.assertEqual(datespan.get_validation_reason(),
                      "You are limited to a span of 90 days, but this date range spans 181 days")
Esempio n. 9
0
 def test_datespan_ok(self):
     datespan = DateSpan(datetime(2015, 01, 01), datetime(2015, 04, 01), max_days=90)
     self.assertTrue(datespan.is_valid())
Esempio n. 10
0
 def test_wrong_century(self):
     datespan = DateSpan(datetime(1815, 01, 01), datetime(1815, 02, 01))
     self.assertFalse(datespan.is_valid())
     self.assertEqual(datespan.get_validation_reason(), "You can't use dates earlier than the year 1900")
Esempio n. 11
0
 def test_date_missing(self):
     datespan = DateSpan(datetime(2015, 01, 01), None)
     self.assertFalse(datespan.is_valid())
     self.assertEqual(datespan.get_validation_reason(), "You have to specify both dates!")
Esempio n. 12
0
 def test_ok(self):
     datespan = DateSpan(datetime(2015, 01, 01), datetime(2015, 02, 01))
     self.assertTrue(datespan.is_valid())
     self.assertEqual(datespan.get_validation_reason(), "")