def test_should_reject_easily_mistaken_dateutil_arguments( self, invalid_period): low = datetime(2014, 6, 15) period = datetime(2014, 6, 25) with self.assertRaisesRegexp( ValueError, "Invalid period: {}".format(invalid_period)): date.get_intersecting_periods(low, period, period=invalid_period).next()
def test_should_one_date_for_each_month(self, low, high, expected_results): results = list(date.get_intersecting_periods(low, high, period='month')) self.assertEquals(expected_results, results)
def test_date_arguments_and_date_range_with_default_post_days(self): low = datetime(2014, 6, 15) high = datetime(2014, 6, 16) dates = list(date.get_intersecting_periods(low, high)) self.assertEquals(1, len(dates)) self.assertEquals(low, dates[0])
def test_empty_period(self, low, high): results = list(date.get_intersecting_periods(low, high, period='month')) self.assertEquals([], results)
def test_periods(self, low, high, period, expected_results): results = list(date.get_intersecting_periods(low, high, period=period)) self.assertEquals(expected_results, results)
def when_intersecting_period_calculated(self, low, high, period_size): try: self.result = list( date.get_intersecting_periods(low, high, period=period_size)) except Exception as error: self.error = error
def when_intersecting_period_calculated(self, low, high, period_size): try: self.result = list(date.get_intersecting_periods(low, high, period=period_size)) except Exception as error: self.error = error
def test_should_reject_easily_mistaken_dateutil_arguments(self, invalid_period): low = datetime(2014, 6, 15) period = datetime(2014, 6, 25) with self.assertRaisesRegexp(ValueError, "Invalid period: {}".format(invalid_period)): date.get_intersecting_periods(low, period, period=invalid_period).next()