Beispiel #1
0
 def testExpired(self):
     "Dates in the past should be expired."
     now = datetime.datetime.now()
     month = now.month
     year = now.year - 2
     expiry = ExpiryDate(month=month, year=year)
     assert expiry.is_expired()
Beispiel #2
0
 def testNotExpired(self):
     "Dates in the future should be expired."
     now = datetime.datetime.now()
     month = now.month
     year = now.year + 2
     expiry = ExpiryDate(month=month, year=year)
     self.assertFalse(expiry.is_expired())
Beispiel #3
0
 def testCorrectExpirationDate(self):
     """
     Expiration date should equal to the last second
     of the last day of the month/year specified.
     """
     now = datetime.datetime.now()
     expiry = ExpiryDate(month=now.month, year=now.year)
     expected = datetime.datetime(
                 now.year, now.month, 
                 calendar.monthrange(now.year, now.month)[1],
                 23, 59, 59, 59)
     self.assertEqual(expiry.expiration(), expected)
Beispiel #4
0
 def testTodayNotExpired(self):
     "Today should not be expired."
     now = datetime.datetime.now()
     expiry = ExpiryDate(month=now.month, year=now.year)
     self.assertFalse(expiry.is_expired())