Пример #1
0
    def test_parse_time_with_14_days_in_seconds(self):
        seconds = 14 * 24 * 60 * 60
        now = datetime.datetime.now()
        then = now + datetime.timedelta(seconds=seconds)

        expire_at = Cache._parse_time(seconds)
        self.assertTrue((expire_at - then).seconds <= 5)
Пример #2
0
 def test_parse_time_with_32_days_in_seconds(self):
     # Only 31 days in seconds are appropriate, otherwise it gets handled
     # as a unix timestamp
     seconds = 32 * 24 * 60 * 60
     self.assertEquals(Cache._parse_time(seconds),
         datetime.datetime.fromtimestamp(seconds))
Пример #3
0
 def test_parse_time_with_zero(self):
     self.assertEquals(Cache._parse_time(0), datetime.datetime(
         year=datetime.MAXYEAR, month=12, day=31))