Пример #1
0
 def test_start_at_midnight(self):
     self.assertEqual(
         subdivide_interval_by_hour(
             datetime(2010, 6, 6, 0, 0),
             datetime(2010, 6, 6, 0, 3),
         ),
         {datetime(2010, 6, 6, 0): 180.0}
     )
Пример #2
0
 def test_end_at_midnight(self):
     self.assertEqual(
         subdivide_interval_by_hour(
             datetime(2010, 6, 5, 23, 55),
             datetime(2010, 6, 6, 0, 0),
         ),
         {datetime(2010, 6, 5, 23): 300.0}
     )
Пример #3
0
 def test_zero_interval(self):
     self.assertEqual(
         subdivide_interval_by_hour(
             datetime(2010, 6, 6, 4, 26),
             datetime(2010, 6, 6, 4, 26),
         ),
         {}
     )
Пример #4
0
 def test_same_hour(self):
     self.assertEqual(
         subdivide_interval_by_hour(
             datetime(2010, 6, 6, 4, 24),
             datetime(2010, 6, 6, 4, 26),
         ),
         {datetime(2010, 6, 6, 4): 120.0}
     )
Пример #5
0
 def test_split_over_midnight(self):
     self.assertEqual(
         subdivide_interval_by_hour(
             datetime(2010, 6, 5, 23, 55),
             datetime(2010, 6, 6, 0, 3),
         ),
         {datetime(2010, 6, 5, 23): 300.0,
          datetime(2010, 6, 6, 0): 180.0}
     )
Пример #6
0
 def test_split_over_midnight(self):
     self.assertEqual(
         subdivide_interval_by_hour(
             datetime(2010, 6, 5, 23, 55),
             datetime(2010, 6, 6, 0, 3),
         ), {
             datetime(2010, 6, 5, 23): 300.0,
             datetime(2010, 6, 6, 0): 180.0
         })
Пример #7
0
 def test_full_hours(self):
     self.assertEqual(
         subdivide_interval_by_hour(datetime(2010, 6, 5, 23, 40), datetime(2010, 6, 6, 2, 10)),
         {
             datetime(2010, 6, 5, 23): 1200.0,
             datetime(2010, 6, 6, 0): 3600.0,
             datetime(2010, 6, 6, 1): 3600.0,
             datetime(2010, 6, 6, 2): 600.0,
         },
     )
Пример #8
0
 def test_full_hours(self):
     self.assertEqual(
         subdivide_interval_by_hour(
             datetime(2010, 6, 5, 23, 40),
             datetime(2010, 6, 6, 2, 10),
         ), {
             datetime(2010, 6, 5, 23): 1200.0,
             datetime(2010, 6, 6, 0): 3600.0,
             datetime(2010, 6, 6, 1): 3600.0,
             datetime(2010, 6, 6, 2): 600.0
         })
Пример #9
0
 def test_end_at_midnight(self):
     self.assertEqual(
         subdivide_interval_by_hour(
             datetime(2010, 6, 5, 23, 55),
             datetime(2010, 6, 6, 0, 0),
         ), {datetime(2010, 6, 5, 23): 300.0})
Пример #10
0
 def test_start_at_midnight(self):
     self.assertEqual(
         subdivide_interval_by_hour(
             datetime(2010, 6, 6, 0, 0),
             datetime(2010, 6, 6, 0, 3),
         ), {datetime(2010, 6, 6, 0): 180.0})
Пример #11
0
 def test_same_hour(self):
     self.assertEqual(
         subdivide_interval_by_hour(
             datetime(2010, 6, 6, 4, 24),
             datetime(2010, 6, 6, 4, 26),
         ), {datetime(2010, 6, 6, 4): 120.0})
Пример #12
0
 def test_zero_interval(self):
     self.assertEqual(
         subdivide_interval_by_hour(
             datetime(2010, 6, 6, 4, 26),
             datetime(2010, 6, 6, 4, 26),
         ), {})