def test_makes_right_number_of_dates(self): """ Test that it makes an ndarray, that they are datetime objects and has right length :return: None """ dates = rts.make_dates(15) self.assertTrue(isinstance(dates, np.ndarray)) self.assertTrue(isinstance(dates[0], datetime.datetime)) self.assertEquals(len(dates), 15)
def test_exact_2_months(self): """ Test that it returns expected results with 2 month cadence :return: """ time_unit = (2, 'months') dates = rts.make_dates(3, time_unit=time_unit, start_date=None) expected = np.array([datetime.datetime(2015, 1, 1, 0, 0), datetime.datetime(2015, 3, 2, 21, 0), datetime.datetime(2015, 5, 2, 18, 0)], dtype=object) for d, e in zip(dates, expected): self.assertEquals(d, e)
def test_exact_1_day(self): """ Test that it returns expected results with 1 day cadence :return: """ time_unit = (1, 'day') dates = rts.make_dates(3, time_unit=time_unit, start_date=None) expected = np.array([datetime.datetime(2015, 1, 1, 0, 0), datetime.datetime(2015, 1, 2, 0, 0), datetime.datetime(2015, 1, 3, 0, 0)], dtype=object) for d, e in zip(dates, expected): self.assertEquals(d, e)