Skip to content

Commit

Permalink
Test read_cube operator
Browse files Browse the repository at this point in the history
  • Loading branch information
jfrost-mo committed Dec 11, 2023
1 parent b9adb6a commit d959d9f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/operators/test_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""Reading operator tests."""

import iris.cube
import pytest

from CSET.operators import constraints, read

Expand Down Expand Up @@ -63,3 +64,18 @@ def test_fieldsfile_ensemble_naming():
filename = "myfieldsfile_enuk_um_001/enukaa_pd000"
read._ensemble_callback(cube, None, filename)
assert cube.coord("realization").points[0] == 1


def test_read_cube():
"""Returns a Cube rather than CubeList."""
cube = read.read_cube(
"tests/test_data/air_temp.nc",
constraint=constraints.generate_cell_methods_constraint([]),
)
assert isinstance(cube, iris.cube.Cube)


def test_read_cube_unconstrained():
"""Error for multiple cubes read."""
with pytest.raises(ValueError):
read.read_cube("tests/test_data/air_temp.nc")

0 comments on commit d959d9f

Please sign in to comment.