예제 #1
0
 def test_c(self):
     """Test the value before the second date & time is the first value."""
     today = datetime(2010, 12, 20)
     timeserie = TimeseriesWithMemoryStub((today, 20.0),
                                          (today + timedelta(2), 30.0))
     tomorrow = today + timedelta(1)
     self.assertAlmostEqual(20.0, timeserie.get_value(tomorrow))
예제 #2
0
 def test_c(self):
     """Test the value before the second date & time is the first value."""
     today = datetime(2010, 12, 20)
     timeserie = TimeseriesWithMemoryStub((today, 20.0),
                                          (today + timedelta(2), 30.0))
     tomorrow = today + timedelta(1)
     self.assertAlmostEqual(20.0, timeserie.get_value(tomorrow))
예제 #3
0
    def test_d(self):
        """Test missing dates are automatically added as the latest known
        value.

        """
        timeserie = TimeseriesWithMemoryStub()
        today = datetime(2010, 12, 3)
        tomorrow = datetime(2010, 12, 4)
        day_after_tomorrow = datetime(2010, 12, 5)
        timeserie.add_value(today, 20)
        timeserie.add_value(day_after_tomorrow, 30)
        events = [event for event in timeserie.events()]
        expected_events = \
            [(today, 20), (tomorrow, 20), (day_after_tomorrow, 30)]
        self.assertEqual(expected_events, events)
예제 #4
0
    def test_d(self):
        """Test missing dates are automatically added as the latest known
        value.

        """
        timeserie = TimeseriesWithMemoryStub()
        today = datetime(2010, 12, 3)
        tomorrow = datetime(2010, 12, 4)
        day_after_tomorrow = datetime(2010, 12, 5)
        timeserie.add_value(today, 20)
        timeserie.add_value(day_after_tomorrow, 30)
        events = [event for event in timeserie.events()]
        expected_events = \
            [(today, 20), (tomorrow, 20), (day_after_tomorrow, 30)]
        self.assertEqual(expected_events, events)
예제 #5
0
 def test_a(self):
     """Test the value on the first date is the first value."""
     today = datetime(2010, 12, 20)
     timeserie = TimeseriesWithMemoryStub((today, 20.0))
     self.assertAlmostEqual(20.0, timeserie.get_value(today))
예제 #6
0
 def test_a(self):
     """Test the value on the first date is the first value."""
     today = datetime(2010, 12, 20)
     timeserie = TimeseriesWithMemoryStub((today, 20.0))
     self.assertAlmostEqual(20.0, timeserie.get_value(today))