コード例 #1
0
 def test_with_hour(self):
     self.expiration = (datetime.now(tzlocal()) +
                        relativedelta(hours=1)).replace(microsecond=0)
     remaining = relativedelta(self.expiration, datetime.now(
         tzutc())) + relativedelta(seconds=30)
     message = get_relative_expiration_time(remaining)
     self.assertEqual(message, '1 hour')
コード例 #2
0
 def test_with_days_minutes(self):
     self.expiration = (datetime.now(tzlocal()) + relativedelta(days=1) +
                        relativedelta(minutes=44)).replace(microsecond=0)
     remaining = relativedelta(self.expiration, datetime.now(
         tzutc())) + relativedelta(seconds=30)
     message = get_relative_expiration_time(remaining)
     self.assertEqual(message, '1 day')
コード例 #3
0
 def test_with_years(self):
     self.expiration = (datetime.now(tzlocal()) +
                        relativedelta(years=2)).replace(microsecond=0)
     remaining = relativedelta(self.expiration, datetime.now(
         tzutc())) + relativedelta(seconds=30)
     message = get_relative_expiration_time(remaining)
     self.assertEqual(message, '1 year and 11 months')
コード例 #4
0
 def test_with_full_time(self):
     remaining = relativedelta(years=2,
                               months=3,
                               days=7,
                               hours=11,
                               minutes=44)
     message = get_relative_expiration_time(remaining)
     self.assertEqual(message, '2 years and 3 months')
コード例 #5
0
 def test_with_years_month(self):
     remaining = relativedelta(years=3,
                               days=30,
                               hours=23,
                               minutes=59,
                               seconds=30)
     message = get_relative_expiration_time(remaining)
     self.assertEqual(message, '3 years')
コード例 #6
0
 def test_with_full_time(self):
     self.expiration = (datetime.now(tzlocal()) + relativedelta(years=2) +
                        relativedelta(months=3) + relativedelta(days=7) +
                        relativedelta(hours=11) +
                        relativedelta(minutes=44)).replace(microsecond=0)
     remaining = relativedelta(self.expiration, datetime.now(
         tzutc())) + relativedelta(seconds=30)
     message = get_relative_expiration_time(remaining)
     self.assertEqual(message, '2 years and 3 months')
コード例 #7
0
 def test_with_minutes_seconds(self):
     remaining = relativedelta(hours=1)
     message = get_relative_expiration_time(remaining)
     self.assertEqual(message, '1 hour')
コード例 #8
0
 def test_with_day(self):
     remaining = relativedelta(days=1)
     message = get_relative_expiration_time(remaining)
     self.assertEqual(message, '1 day')
コード例 #9
0
 def test_with_years_days_hours_minutes(self):
     remaining = relativedelta(years=2, days=7, hours=11, minutes=44)
     message = get_relative_expiration_time(remaining)
     self.assertEqual(message, '2 years')
コード例 #10
0
 def test_with_years(self):
     remaining = relativedelta(years=1, months=11)
     message = get_relative_expiration_time(remaining)
     self.assertEqual(message, '1 year and 11 months')
コード例 #11
0
 def test_with_year(self):
     remaining = relativedelta(months=11, days=30)
     message = get_relative_expiration_time(remaining)
     self.assertEqual(message, '11 months and 30 days')
コード例 #12
0
 def test_with_years_days(self):
     remaining = relativedelta(years=1, days=9)
     message = get_relative_expiration_time(remaining)
     self.assertEqual(message, '1 year')