diff --git a/lib/iris/tests/test_constraints.py b/lib/iris/tests/test_constraints.py index 0026fe0ee8..adc8611fca 100644 --- a/lib/iris/tests/test_constraints.py +++ b/lib/iris/tests/test_constraints.py @@ -68,6 +68,27 @@ def test_constraints(self): sub_list = self.slices.extract(constraint) self.assertEqual(len(sub_list), 70 * 6) + def test_coord_availability(self): + # "model_level_number" coordinate available + constraint = iris.Constraint(model_level_number=lambda x: True) + result = self.slices.extract(constraint) + self.assertTrue(result) + + # "wibble" coordinate is not available + constraint = iris.Constraint(wibble=lambda x: False) + result = self.slices.extract(constraint) + self.assertFalse(result) + + # "wibble" coordinate is not available + constraint = iris.Constraint(wibble=lambda x: True) + result = self.slices.extract(constraint) + self.assertFalse(result) + + # "lambda x: False" always (confusingly) throws away the cube + constraint = iris.Constraint(model_level_number=lambda x: False) + result = self.slices.extract(constraint) + self.assertFalse(result) + def test_mismatched_type(self): constraint = iris.Constraint(model_level_number="aardvark") sub_list = self.slices.extract(constraint)