Ejemplo n.º 1
0
def test_check_input_cube_time(local_time, expect_success):
    """Checks that check_input_cube_time can differentiate between arguments that match
    expected times and arguments that don't."""
    cube = make_input_cube([3, 4])
    timezone_cube = make_timezone_cube()
    plugin = TimezoneExtraction()
    plugin.check_input_cube_dims(cube, timezone_cube)
    if expect_success:
        plugin.check_input_cube_time(cube, local_time)
    else:
        with pytest.raises(
            ValueError, match=r"Time coord on input cube does not match required times."
        ):
            plugin.check_input_cube_time(cube, local_time)
Ejemplo n.º 2
0
def test_check_input_cube_dims(include_time_coord):
    """Checks that check_input_cube_dims can differentiate between an input cube
    with time, y, x coords and one where time is missing. Also checks that timezone_cube
    has been reordered correctly."""
    cube = make_input_cube([3, 4])
    timezone_cube = make_timezone_cube()
    plugin = TimezoneExtraction()
    if include_time_coord:
        plugin.check_input_cube_dims(cube, timezone_cube)
        assert plugin.timezone_cube.coord_dims("UTC_offset") == tuple(
            [plugin.timezone_cube.ndim - 1])
    else:
        cube.remove_coord("time")
        with pytest.raises(
                ValueError,
                match=r"Expected coords on input_cube: time, y, x "):
            plugin.check_input_cube_dims(cube, timezone_cube)