def test_m(self):
     """Test compute_timeseries supplies the correct time serie values."""
     today = datetime(2010,12,2)
     tomorrow = datetime(2010,12,3)
     evaporation = TimeseriesStub()
     evaporation.add_value(today, 20)
     evaporation.add_value(tomorrow, 30)
     precipitation = TimeseriesStub()
     precipitation.add_value(today, 5)
     precipitation.add_value(tomorrow, 10)
     seepage = TimeseriesStub()
     seepage.add_value(today, 10)
     seepage.add_value(tomorrow, 20)
     mock = Mock({"compute": (0, 0, 0, 0, 0)})
     # we do not need the return value of the next call and we discard it
     compute_timeseries(self.bucket,
                        evaporation,
                        precipitation,
                        seepage,
                        mock.compute)
     calls_to_compute = mock.getNamedCalls('compute')
     self.assertEqual(2, len(calls_to_compute))
     supplied_precipitation = calls_to_compute[1].getParam(2)
     expected_precipitation = 30
     self.assertAlmostEqual(supplied_precipitation, expected_precipitation)
     supplied_evaporation = calls_to_compute[1].getParam(3)
     expected_evaporation = 10
     self.assertAlmostEqual(supplied_evaporation, expected_evaporation)
     supplied_seepage = calls_to_compute[1].getParam(4)
     expected_seepage = 20
     self.assertAlmostEqual(supplied_seepage, expected_seepage)
    def test_k(self):
        """Test compute_timeseries starts with the correct initial water volume."""
        today = datetime(2010,12,2)
        evaporation = TimeseriesStub()
        evaporation.add_value(today, 20)
        precipitation = TimeseriesStub()
        precipitation.add_value(today, 5)
        seepage = TimeseriesStub()
        seepage.add_value(today, 10)
        mock = Mock({"compute": (0, 0, 0, 0, 0)})
        # we do not need the return value of the next call and we discard it
        compute_timeseries(self.bucket,
                           evaporation,
                           precipitation,
                           seepage,
                           mock.compute)
        calls_to_compute = mock.getNamedCalls('compute')
        self.assertTrue(len(calls_to_compute) > 0)

        supplied_volume = calls_to_compute[0].getParam(1)
        expected_volume = self.bucket.init_water_level * self.bucket.surface * self.bucket.porosity
        self.assertAlmostEqual(supplied_volume, expected_volume)