Example #1
0
 def test_start_at_midnight(self):
     self.assertEqual(
         subdivide_interval_by_date(
             datetime(2010, 6, 6, 0, 0),
             datetime(2010, 6, 6, 5, 0),
         ),
         {date(2010, 6, 6): 18000.0}
     )
Example #2
0
 def test_end_at_midnight(self):
     self.assertEqual(
         subdivide_interval_by_date(
             datetime(2010, 6, 5, 23, 0),
             datetime(2010, 6, 6, 0, 0),
         ),
         {date(2010, 6, 5): 3600.0}
     )
Example #3
0
 def test_zero_interval(self):
     self.assertEqual(
         subdivide_interval_by_date(
             datetime(2010, 6, 6, 4, 26),
             datetime(2010, 6, 6, 4, 26),
         ),
         {}
     )
Example #4
0
 def test_same_day(self):
     self.assertEqual(
         subdivide_interval_by_date(
             datetime(2010, 6, 6, 4, 0),
             datetime(2010, 6, 6, 6, 0),
         ),
         {date(2010, 6, 6): 7200.0}
     )
Example #5
0
 def test_split_over_midnight(self):
     self.assertEqual(
         subdivide_interval_by_date(
             datetime(2010, 6, 5, 23, 0),
             datetime(2010, 6, 6, 5, 0),
         ),
         {date(2010, 6, 5): 3600.0,
          date(2010, 6, 6): 18000.0}
     )
 def test_split_over_midnight(self):
     self.assertEqual(
         subdivide_interval_by_date(
             datetime(2010, 6, 5, 23, 0),
             datetime(2010, 6, 6, 5, 0),
         ), {
             date(2010, 6, 5): 3600.0,
             date(2010, 6, 6): 18000.0
         })
Example #7
0
 def test_full_days(self):
     self.assertEqual(
         subdivide_interval_by_date(datetime(2010, 6, 5, 23, 0), datetime(2010, 6, 10, 5, 0)),
         {
             date(2010, 6, 5): 3600.0,
             date(2010, 6, 6): 86400.0,
             date(2010, 6, 7): 86400.0,
             date(2010, 6, 8): 86400.0,
             date(2010, 6, 9): 86400.0,
             date(2010, 6, 10): 18000.0,
         },
     )
 def test_full_days(self):
     self.assertEqual(
         subdivide_interval_by_date(
             datetime(2010, 6, 5, 23, 0),
             datetime(2010, 6, 10, 5, 0),
         ), {
             date(2010, 6, 5): 3600.0,
             date(2010, 6, 6): 86400.0,
             date(2010, 6, 7): 86400.0,
             date(2010, 6, 8): 86400.0,
             date(2010, 6, 9): 86400.0,
             date(2010, 6, 10): 18000.0
         })
 def test_end_at_midnight(self):
     self.assertEqual(
         subdivide_interval_by_date(
             datetime(2010, 6, 5, 23, 0),
             datetime(2010, 6, 6, 0, 0),
         ), {date(2010, 6, 5): 3600.0})
 def test_start_at_midnight(self):
     self.assertEqual(
         subdivide_interval_by_date(
             datetime(2010, 6, 6, 0, 0),
             datetime(2010, 6, 6, 5, 0),
         ), {date(2010, 6, 6): 18000.0})
 def test_same_day(self):
     self.assertEqual(
         subdivide_interval_by_date(
             datetime(2010, 6, 6, 4, 0),
             datetime(2010, 6, 6, 6, 0),
         ), {date(2010, 6, 6): 7200.0})
 def test_zero_interval(self):
     self.assertEqual(
         subdivide_interval_by_date(
             datetime(2010, 6, 6, 4, 26),
             datetime(2010, 6, 6, 4, 26),
         ), {})