def test_all_input(self): self.assertEqual(Minutes.filter(self.datetimes, number=5, now=self.now), set([datetime(1999, 12, 31, 23, 57, 0, 0), datetime(1999, 12, 31, 23, 59, 59, 999999), datetime(2000, 1, 1, 0, 0, 0, 0), datetime(2000, 1, 1, 0, 1, 0, 0)])) self.assertEqual(Minutes.filter(self.datetimes, number=6, now=self.now), set([datetime(1999, 12, 31, 23, 57, 0, 0), datetime(1999, 12, 31, 23, 59, 59, 999999), datetime(2000, 1, 1, 0, 0, 0, 0), datetime(2000, 1, 1, 0, 1, 0, 0)]))
def test_duplicates(self): # Ensure we get the oldest per-minute datetime when there are # duplicates: i.e. not datetime(2000, 1, 1, 0, 0, 1, 0) self.assertEqual(Minutes.filter(self.datetimes, number=2, now=self.now), set([datetime(2000, 1, 1, 0, 0, 0, 0), datetime(2000, 1, 1, 0, 1, 0, 0)]))
def test_microseconds(self): self.assertEqual( Minutes.filter(self.datetimes, number=3, now=self.now), set([ datetime(1999, 12, 31, 23, 59, 59, 999999), datetime(2000, 1, 1, 0, 0, 0, 0), datetime(2000, 1, 1, 0, 1, 0, 0) ]))
def test_before_start(self): # datetime(1999, 12, 31, 23, 57, 0, 0) is too old to show up # in the results self.assertEqual(Minutes.filter(self.datetimes, number=4, now=self.now), set([datetime(1999, 12, 31, 23, 59, 59, 999999), datetime(2000, 1, 1, 0, 0, 0, 0), datetime(2000, 1, 1, 0, 1, 0, 0)]))
def test_duplicates(self): # Ensure we get the oldest per-minute datetime when there are # duplicates: i.e. not datetime(2000, 1, 1, 0, 0, 1, 0) self.assertEqual( Minutes.filter(self.datetimes, number=2, now=self.now), set([ datetime(2000, 1, 1, 0, 0, 0, 0), datetime(2000, 1, 1, 0, 1, 0, 0) ]))
def test_all_input(self): self.assertEqual( Minutes.filter(self.datetimes, number=5, now=self.now), set([ datetime(1999, 12, 31, 23, 57, 0, 0), datetime(1999, 12, 31, 23, 59, 59, 999999), datetime(2000, 1, 1, 0, 0, 0, 0), datetime(2000, 1, 1, 0, 1, 0, 0) ])) self.assertEqual( Minutes.filter(self.datetimes, number=6, now=self.now), set([ datetime(1999, 12, 31, 23, 57, 0, 0), datetime(1999, 12, 31, 23, 59, 59, 999999), datetime(2000, 1, 1, 0, 0, 0, 0), datetime(2000, 1, 1, 0, 1, 0, 0) ]))
def test_before_start(self): # datetime(1999, 12, 31, 23, 57, 0, 0) is too old to show up # in the results self.assertEqual( Minutes.filter(self.datetimes, number=4, now=self.now), set([ datetime(1999, 12, 31, 23, 59, 59, 999999), datetime(2000, 1, 1, 0, 0, 0, 0), datetime(2000, 1, 1, 0, 1, 0, 0) ]))
def test_current(self): self.assertEqual( Minutes.filter(self.datetimes, number=1, now=self.now), set([datetime(2000, 1, 1, 0, 1, 0, 0)]))
def test_no_results(self): self.assertEqual(Minutes.filter([self.now], number=0, now=self.now), set()) self.assertEqual( Minutes.filter(self.datetimes, number=0, now=self.now), set())
def test_no_input(self): self.assertEqual(Minutes.filter([], number=1, now=self.now), set())
def test_future(self): datetimes = [datetime(2010, 1, 15, 0, 0, 0, 0)] # Wikipedia self.assertEqual(Minutes.filter(datetimes, number=0, now=self.now), set(datetimes)) self.assertEqual(Minutes.filter(datetimes, number=1, now=self.now), set(datetimes))
def test_microseconds(self): self.assertEqual(Minutes.filter(self.datetimes, number=3, now=self.now), set([datetime(1999, 12, 31, 23, 59, 59, 999999), datetime(2000, 1, 1, 0, 0, 0, 0), datetime(2000, 1, 1, 0, 1, 0, 0)]))
def test_current(self): self.assertEqual(Minutes.filter(self.datetimes, number=1, now=self.now), set([datetime(2000, 1, 1, 0, 1, 0, 0)]))
def test_no_results(self): self.assertEqual(Minutes.filter([self.now], number=0, now=self.now), set()) self.assertEqual(Minutes.filter(self.datetimes, number=0, now=self.now), set())
def test_mask(self): self.assertEqual( Minutes.mask(datetime(1999, 12, 31, 23, 59, 59, 999999)), datetime(1999, 12, 31, 23, 59, 0, 0))
def test_mask(self): self.assertEqual( Minutes.mask(datetime(1999, 12, 31, 23, 59, 59, 999999)), datetime(1999, 12, 31, 23, 59, 0, 0) )