Skip to content

Commit

Permalink
add constraint test (#1)
Browse files Browse the repository at this point in the history
* add constraint test

* review actions

* update comment
  • Loading branch information
bjlittle authored Dec 7, 2020
1 parent cce44b9 commit 5cbe12d
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/iris/tests/test_constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5cbe12d

Please sign in to comment.