Ejemplo n.º 1
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))
Ejemplo n.º 2
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))
Ejemplo 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"
     )
Ejemplo n.º 4
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")
Ejemplo n.º 5
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!")
Ejemplo n.º 6
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(), "")
Ejemplo n.º 7
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")
Ejemplo n.º 8
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")
Ejemplo n.º 9
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!")
Ejemplo n.º 10
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(), "")