From 317843a6ea9e1db23d40f5937f7454053956294e Mon Sep 17 00:00:00 2001 From: "benjamin.ayliffe" Date: Mon, 14 Feb 2022 15:56:04 +0000 Subject: [PATCH] Add unit tests for new is_model_blended function. --- improver_tests/utilities/test_cube_checker.py | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/improver_tests/utilities/test_cube_checker.py b/improver_tests/utilities/test_cube_checker.py index 580112de1e..02c66c6801 100644 --- a/improver_tests/utilities/test_cube_checker.py +++ b/improver_tests/utilities/test_cube_checker.py @@ -46,6 +46,7 @@ check_cube_coordinates, check_for_x_and_y_axes, find_dimension_coordinate_mismatch, + is_model_blended, spatial_coords_match, ) @@ -301,5 +302,29 @@ def test_unmatching_y(self): self.assertFalse(result) +class Test_is_model_blended(unittest.TestCase): + + """Test is_model_blended behaves as expected.""" + + def setUp(self): + """Set up a cube.""" + data = np.ones((1, 5, 5), dtype=np.float32) + cube = set_up_variable_cube( + data, "precipitation_amount", "kg m^-2", "equalarea", + ) + self.cube_without = cube + blend_time = cube.coord("forecast_reference_time").copy() + blend_time.rename("blend_time") + self.cube_with = cube.copy() + self.cube_with.add_aux_coord(blend_time) + + def test_basic(self): + """Test correct result is returned for cube with and without a + blend_time coordinate.""" + + self.assertFalse(is_model_blended(self.cube_without)) + self.assertTrue(is_model_blended(self.cube_with)) + + if __name__ == "__main__": unittest.main()