def test_years_hours_and_minutes(self): obj = amazonndt.AmazonDuration("P2YT3H10M") self.assertEqual(dt.timedelta(weeks=2 * 52, hours=3, minutes=10), obj.timedelta)
def test_all_values(self): obj = amazonndt.AmazonDuration("P3Y4M2W1DT5H10M42S")
def test_months(self): obj = amazonndt.AmazonDuration("P4M") self.assertEqual(dt.timedelta(weeks=16), obj.timedelta)
def test_hours_and_minutes(self): obj = amazonndt.AmazonDuration("PT5H10M") self.assertEqual(dt.timedelta(hours=5, minutes=10), obj.timedelta)
def test_weeks(self): obj = amazonndt.AmazonDuration("P8W") self.assertEqual(dt.timedelta(weeks=8), obj.timedelta)
def test_years(self): obj = amazonndt.AmazonDuration("P7Y") self.assertEqual(dt.timedelta(weeks=52 * 7), obj.timedelta)
def test_seconds(self): obj = amazonndt.AmazonDuration("PT45S") self.assertEqual(dt.timedelta(seconds=45), obj.timedelta)
def test_days(self): obj = amazonndt.AmazonDuration("P3D") self.assertEqual(dt.timedelta(days=3), obj.timedelta)
def test_hours(self): obj = amazonndt.AmazonDuration("PT5H") self.assertEqual(dt.timedelta(hours=5), obj.timedelta)
def test_minutes(self): obj = amazonndt.AmazonDuration("PT10M") self.assertEqual(dt.timedelta(minutes=10), obj.timedelta)
def test_raises_on_parse_error(self): with self.assertRaises(ValueError): obj = amazonndt.AmazonDuration("blah")