class Test__spatial_domain_match(SetupCoefficientsCubes):

    """ Test the _spatial_domain_match method."""

    def setUp(self):
        super().setUp()
        self.plugin = Plugin()

    def test_matching(self):
        """Test case in which spatial domains match."""
        self.plugin.current_forecast = self.current_temperature_forecast_cube
        self.plugin.coefficients_cubelist = self.coeffs_from_mean
        self.plugin._spatial_domain_match()

    def test_unmatching_x_axis_points(self):
        """Test when the points of the x dimension do not match."""
        self.current_temperature_forecast_cube.coord(axis="x").bounds = (
            self.current_temperature_forecast_cube.coord(axis="x").bounds + 2.0
        )
        self.plugin.current_forecast = self.current_temperature_forecast_cube
        self.plugin.coefficients_cubelist = self.coeffs_from_mean
        msg = "The points or bounds of the x axis given by the current forecast"
        with self.assertRaisesRegex(ValueError, msg):
            self.plugin._spatial_domain_match()

    def test_unmatching_x_axis_bounds(self):
        """Test when the bounds of the x dimension do not match."""
        self.current_temperature_forecast_cube.coord(axis="x").bounds = [
            [-35, -5],
            [-5, 5],
            [5, 35],
        ]
        self.plugin.current_forecast = self.current_temperature_forecast_cube
        self.plugin.coefficients_cubelist = self.coeffs_from_mean
        msg = "The points or bounds of the x axis given by the current forecast"
        with self.assertRaisesRegex(ValueError, msg):
            self.plugin._spatial_domain_match()

    def test_unmatching_y_axis(self):
        """Test case in which the y-dimensions of the domains do not match."""
        self.current_temperature_forecast_cube.coord(axis="y").bounds = (
            self.current_temperature_forecast_cube.coord(axis="y").bounds + 2.0
        )
        self.plugin.current_forecast = self.current_temperature_forecast_cube
        self.plugin.coefficients_cubelist = self.coeffs_from_mean
        msg = "The points or bounds of the y axis given by the current forecast"
        with self.assertRaisesRegex(ValueError, msg):
            self.plugin._spatial_domain_match()

    def test_skipping_spot_forecast(self):
        """Test passing a spot forecast. In this case, the spatial domain
        is not checked."""
        self.plugin.current_forecast = self.current_forecast_spot_cube
        self.plugin._spatial_domain_match()
class Test__spatial_domain_match(SetupCoefficientsCubes):
    """ Test the _spatial_domain_match method."""
    def setUp(self):
        super().setUp()
        self.plugin = Plugin()

    def test_matching(self):
        """Test case in which spatial domains match."""
        self.plugin.current_forecast = self.current_temperature_forecast_cube
        self.plugin.coefficients_cube = self.coeffs_from_mean
        self.plugin._spatial_domain_match()

    def test_unmatching_x_axis(self):
        """Test case in which the x-dimensions of the domains do not match."""
        self.current_temperature_forecast_cube.coord(axis="x").points = (
            self.current_temperature_forecast_cube.coord(axis="x").points *
            2.0)
        self.plugin.current_forecast = self.current_temperature_forecast_cube
        self.plugin.coefficients_cube = self.coeffs_from_mean
        msg = "The domain along the x axis given by the current forecast"
        with self.assertRaisesRegex(ValueError, msg):
            self.plugin._spatial_domain_match()

    def test_unmatching_y_axis(self):
        """Test case in which the y-dimensions of the domains do not match."""
        self.current_temperature_forecast_cube.coord(axis="y").points = (
            self.current_temperature_forecast_cube.coord(axis="y").points *
            2.0)
        self.plugin.current_forecast = self.current_temperature_forecast_cube
        self.plugin.coefficients_cube = self.coeffs_from_mean
        msg = "The domain along the y axis given by the current forecast"
        with self.assertRaisesRegex(ValueError, msg):
            self.plugin._spatial_domain_match()