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')
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')
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')
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')
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')
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')
def test_with_minutes_seconds(self): remaining = relativedelta(hours=1) message = get_relative_expiration_time(remaining) self.assertEqual(message, '1 hour')
def test_with_day(self): remaining = relativedelta(days=1) message = get_relative_expiration_time(remaining) self.assertEqual(message, '1 day')
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')
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')
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')
def test_with_years_days(self): remaining = relativedelta(years=1, days=9) message = get_relative_expiration_time(remaining) self.assertEqual(message, '1 year')