|
4 | 4 |
|
5 | 5 | import pytest |
6 | 6 | from pygmt import Figure, grdcut |
7 | | -from pygmt.exceptions import GMTTypeError |
| 7 | +from pygmt.exceptions import GMTInvalidInput, GMTTypeError |
8 | 8 | from pygmt.helpers import GMTTempFile |
9 | 9 | from pygmt.helpers.testing import load_static_earth_relief |
10 | 10 |
|
@@ -252,3 +252,34 @@ def test_grdview_wrong_kind_of_drapegrid(xrgrid): |
252 | 252 | fig = Figure() |
253 | 253 | with pytest.raises(GMTTypeError): |
254 | 254 | fig.grdview(grid=xrgrid, drapegrid=dataset) |
| 255 | + |
| 256 | + |
| 257 | +def test_grdview_invalid_surftype(gridfile): |
| 258 | + """ |
| 259 | + Test grdview with an invalid surftype or invalid combination of surftype and other |
| 260 | + parameters. |
| 261 | + """ |
| 262 | + fig = Figure() |
| 263 | + with pytest.raises(GMTInvalidInput): |
| 264 | + fig.grdview(grid=gridfile, surftype="invalid_surftype") |
| 265 | + with pytest.raises(GMTInvalidInput): |
| 266 | + fig.grdview(grid=gridfile, surftype="surface", dpi=300) |
| 267 | + with pytest.raises(GMTInvalidInput): |
| 268 | + fig.grdview(grid=gridfile, surftype="surface", nan_transparent=True) |
| 269 | + with pytest.raises(GMTInvalidInput): |
| 270 | + fig.grdview(grid=gridfile, surftype="surface", mesh_fill="red") |
| 271 | + |
| 272 | + |
| 273 | +def test_grdview_mixed_syntax(gridfile): |
| 274 | + """ |
| 275 | + Run grdview using grid as a file and drapegrid as an xarray.DataArray. |
| 276 | + """ |
| 277 | + fig = Figure() |
| 278 | + with pytest.raises(GMTInvalidInput): |
| 279 | + fig.grdview(grid=gridfile, cmap="oleron", surftype="i", dpi=300) |
| 280 | + with pytest.raises(GMTInvalidInput): |
| 281 | + fig.grdview(grid=gridfile, cmap="oleron", surftype="m", mesh_fill="red") |
| 282 | + with pytest.raises(GMTInvalidInput): |
| 283 | + fig.grdview(grid=gridfile, cmap="oleron", surftype="s", monochrome=True) |
| 284 | + with pytest.raises(GMTInvalidInput): |
| 285 | + fig.grdview(grid=gridfile, cmap="oleron", surftype="i", nan_transparent=True) |
0 commit comments