Example #1
0
    def test_raises_exception_for_impossible_aggregation(self):
        """Test function raises an exception when attempting to create an
        accumulation_period that cannot be created from the input cubes."""

        plugin = Accumulation(accumulation_period=119)
        msg = "The specified accumulation period "

        with self.assertRaisesRegex(ValueError, msg):
            plugin._check_inputs(self.cubes)
Example #2
0
 def test_specify_accumulation_period(self):
     """Test that the expected time interval is returned when the
     accumulation period is specified. Also test that the returned list of
     cubes has the expected units."""
     expected_time_interval = 60
     expected_cubes = self.cubes.copy()
     for cube in expected_cubes:
         cube.convert_units("m/s")
     accumulation_period = 60 * 60
     plugin = Accumulation(accumulation_period=accumulation_period)
     cubes, time_interval = plugin._check_inputs(self.cubes)
     self.assertEqual(cubes, expected_cubes)
     self.assertEqual(time_interval, expected_time_interval)
     self.assertEqual(plugin.accumulation_period, accumulation_period)
Example #3
0
 def test_specify_forecast_period(self):
     """Test that the expected time interval is returned when the forecast
     periods are specified. Also test that the returned list of cubes has
     the expected units."""
     expected_time_interval = 60
     expected_cubes = self.cubes.copy()
     for cube in expected_cubes:
         cube.convert_units("m/s")
     forecast_periods = [600]
     plugin = Accumulation(forecast_periods=forecast_periods)
     cubes, time_interval = plugin._check_inputs(self.cubes)
     self.assertEqual(cubes, expected_cubes)
     self.assertEqual(time_interval, expected_time_interval)
     self.assertEqual(plugin.forecast_periods, forecast_periods)
Example #4
0
 def test_specify_accumulation_period_and_forecast_period(self):
     """Test that the expected time interval is returned when the
     accumulation period and forecast periods are specified. Also test that
     the returned list of cubes has the expected units."""
     expected_time_interval = 60
     expected_cubes = self.cubes.copy()
     for cube in expected_cubes:
         cube.convert_units("m/s")
     accumulation_period = 20 * 60
     forecast_periods = np.array([15]) * 60
     plugin = Accumulation(accumulation_period=accumulation_period,
                           forecast_periods=forecast_periods)
     cubes, time_interval = plugin._check_inputs(self.cubes)
     self.assertEqual(cubes, expected_cubes)
     self.assertEqual(time_interval, expected_time_interval)