Skip to content

Commit

Permalink
Refactor: rename tests & variables.
Browse files Browse the repository at this point in the history
  • Loading branch information
truth-quark committed Aug 30, 2024
1 parent e54c804 commit 9c53c06
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions test/test_um2netcdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ def test_fix_level_coord_skipped_if_no_levels(z_sea_rho_data, z_sea_theta_data):

# tests - fix pressure level data

def test_fix_plevs_no_pressure_coord(get_fake_cube_coords):
def test_fix_pressure_levels_no_pressure_coord(get_fake_cube_coords):
cube = get_fake_cube_coords()

with pytest.raises(iris.exceptions.CoordinateNotFoundError):
Expand All @@ -769,26 +769,26 @@ def _add_attrs_points(m_plevs: mock.MagicMock, points):
setattr(m_plevs, "points", points)


def test_fix_plevs_do_rounding(get_fake_cube_coords):
m_plevs = mock.Mock()
_add_attrs_points(m_plevs, [1.000001, 0.000001])
extra = {"pressure": m_plevs}
def test_fix_pressure_levels_do_rounding(get_fake_cube_coords):
m_pressure = mock.Mock()
_add_attrs_points(m_pressure, [1.000001, 0.000001])
extra = {"pressure": m_pressure}
cube = get_fake_cube_coords(extra)

um2nc.fix_pressure_levels(cube)

# TODO: test flaw, this verifies pressure coord but ignores fix_plevs()
# returning a new cube if the pressure is reversed. This is verified
# in command line testing though
plev = cube.coord('pressure')
assert plev.attributes["positive"] == "down"
assert all(plev.points == [1.0, 0.0])
c_pressure = cube.coord('pressure')
assert c_pressure.attributes["positive"] == "down"
assert all(c_pressure.points == [1.0, 0.0])


def test_fix_plevs_reverse_pressure(get_fake_cube_coords):
m_plevs = mock.Mock()
_add_attrs_points(m_plevs, [0.000001, 1.000001])
extra = {"pressure": m_plevs}
def test_fix_pressure_levels_reverse_pressure(get_fake_cube_coords):
m_pressure = mock.Mock()
_add_attrs_points(m_pressure, [0.000001, 1.000001])
extra = {"pressure": m_pressure}
cube = get_fake_cube_coords(extra)

with mock.patch("iris.util.reverse"):
Expand All @@ -797,6 +797,6 @@ def test_fix_plevs_reverse_pressure(get_fake_cube_coords):
# TODO: test flaw, this verifies pressure coord but ignores fix_plevs()
# returning a new cube if the pressure is reversed. This is verified
# in command line testing though
plev = cube.coord('pressure')
assert plev.attributes["positive"] == "down"
assert all(plev.points == [0.0, 1.0])
c_pressure = cube.coord('pressure')
assert c_pressure.attributes["positive"] == "down"
assert all(c_pressure.points == [0.0, 1.0])

0 comments on commit 9c53c06

Please sign in to comment.