-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Qualify warnings * add samples.lfric warn test coverage * update pytest filterwarnings
- Loading branch information
Showing
9 changed files
with
48 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"""Unit-tests for :func:`geovista.samples.lfric`.""" | ||
from __future__ import annotations | ||
|
||
import pytest | ||
|
||
from geovista.samples import LFRIC_RESOLUTION, lfric | ||
|
||
|
||
def test_resolution_warning(mocker): | ||
"""Test warning raised of invalid cubed-sphere resolution request.""" | ||
processor = mocker.sentinel.processor | ||
_ = mocker.patch("pooch.Decompress", return_value=processor) | ||
resource = mocker.sentinel.resource | ||
_ = mocker.patch("geovista.cache.CACHE.fetch", return_value=resource) | ||
mesh = mocker.sentinel.mesh | ||
_ = mocker.patch("pyvista.read", return_value=mesh) | ||
bad = "r24" | ||
wmsg = f"geovista detected unknown LFRic cubed-sphere resolution {bad!r}" | ||
with pytest.warns(UserWarning, match=wmsg): | ||
result = lfric(resolution=bad) | ||
|
||
import pooch | ||
import pyvista as pv | ||
|
||
from geovista.cache import CACHE | ||
|
||
fname = f"lfric_{LFRIC_RESOLUTION}.vtk" | ||
pooch.Decompress.assert_called_once_with(method="auto", name=fname) | ||
CACHE.fetch.assert_called_once_with(f"mesh/{fname}.bz2", processor=processor) | ||
pv.read.assert_called_once_with(resource) | ||
assert result == mesh |