Esempio n. 1
0
    def test_all_input(self):
        self.assertEqual(Hours.filter(self.datetimes, number=5, now=self.now),
                         set([datetime(1999, 12, 31, 21, 0, 0, 0),
                              datetime(1999, 12, 31, 23, 59, 59, 999999),
                              datetime(2000, 1, 1, 0, 0, 0, 0),
                              datetime(2000, 1, 1, 1, 0, 0, 0)]))

        self.assertEqual(Hours.filter(self.datetimes, number=6, now=self.now),
                         set([datetime(1999, 12, 31, 21, 0, 0, 0),
                              datetime(1999, 12, 31, 23, 59, 59, 999999),
                              datetime(2000, 1, 1, 0, 0, 0, 0),
                              datetime(2000, 1, 1, 1, 0, 0, 0)]))
Esempio n. 2
0
 def test_duplicates(self):
     # Ensure we get the oldest per-hour datetime when there are
     # duplicates: i.e. not datetime(2000, 1, 1, 0, 1, 0, 0)
     self.assertEqual(Hours.filter(self.datetimes, number=2,
                                   now=self.now),
                      set([datetime(2000, 1, 1, 0, 0, 0, 0),
                           datetime(2000, 1, 1, 1, 0, 0, 0)]))
Esempio n. 3
0
 def test_before_start(self):
     # datetime(1999, 12, 31, 21, 0, 0, 0) is too old to show up
     # in the results
     self.assertEqual(Hours.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, 1, 0, 0, 0)]))
Esempio n. 4
0
 def test_microseconds(self):
     self.assertEqual(
         Hours.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, 1, 0, 0, 0)
         ]))
Esempio n. 5
0
    def test_all_input(self):
        self.assertEqual(
            Hours.filter(self.datetimes, number=5, now=self.now),
            set([
                datetime(1999, 12, 31, 21, 0, 0, 0),
                datetime(1999, 12, 31, 23, 59, 59, 999999),
                datetime(2000, 1, 1, 0, 0, 0, 0),
                datetime(2000, 1, 1, 1, 0, 0, 0)
            ]))

        self.assertEqual(
            Hours.filter(self.datetimes, number=6, now=self.now),
            set([
                datetime(1999, 12, 31, 21, 0, 0, 0),
                datetime(1999, 12, 31, 23, 59, 59, 999999),
                datetime(2000, 1, 1, 0, 0, 0, 0),
                datetime(2000, 1, 1, 1, 0, 0, 0)
            ]))
Esempio n. 6
0
 def test_duplicates(self):
     # Ensure we get the oldest per-hour datetime when there are
     # duplicates: i.e. not datetime(2000, 1, 1, 0, 1, 0, 0)
     self.assertEqual(
         Hours.filter(self.datetimes, number=2, now=self.now),
         set([
             datetime(2000, 1, 1, 0, 0, 0, 0),
             datetime(2000, 1, 1, 1, 0, 0, 0)
         ]))
Esempio n. 7
0
 def test_before_start(self):
     # datetime(1999, 12, 31, 21, 0, 0, 0) is too old to show up
     # in the results
     self.assertEqual(
         Hours.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, 1, 0, 0, 0)
         ]))
Esempio n. 8
0
 def test_current(self):
     self.assertEqual(Hours.filter(self.datetimes, number=1, now=self.now),
                      set([datetime(2000, 1, 1, 1, 0, 0, 0)]))
Esempio n. 9
0
 def test_no_results(self):
     self.assertEqual(Hours.filter([self.now], number=0, now=self.now),
                      set())
     self.assertEqual(Hours.filter(self.datetimes, number=0, now=self.now),
                      set())
Esempio n. 10
0
 def test_no_input(self):
     self.assertEqual(Hours.filter([], number=1, now=self.now), set())
Esempio n. 11
0
 def test_future(self):
     datetimes = [datetime(2010, 1, 15, 0, 0, 0, 0)]  # Wikipedia
     self.assertEqual(Hours.filter(datetimes, number=0, now=self.now),
                      set(datetimes))
     self.assertEqual(Hours.filter(datetimes, number=1, now=self.now),
                      set(datetimes))
Esempio n. 12
0
 def test_microseconds(self):
     self.assertEqual(Hours.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, 1, 0, 0, 0)]))
Esempio n. 13
0
 def test_current(self):
     self.assertEqual(Hours.filter(self.datetimes, number=1, now=self.now),
                      set([datetime(2000, 1, 1, 1, 0, 0, 0)]))
Esempio n. 14
0
 def test_no_results(self):
     self.assertEqual(Hours.filter([self.now], number=0, now=self.now),
                      set())
     self.assertEqual(Hours.filter(self.datetimes, number=0, now=self.now),
                      set())
Esempio n. 15
0
 def test_no_input(self):
     self.assertEqual(Hours.filter([], number=1, now=self.now),
                      set())
Esempio n. 16
0
 def test_future(self):
     datetimes = [datetime(2010, 1, 15, 0, 0, 0, 0)]  # Wikipedia
     self.assertEqual(Hours.filter(datetimes, number=0, now=self.now),
                      set(datetimes))
     self.assertEqual(Hours.filter(datetimes, number=1, now=self.now),
                      set(datetimes))