Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip gmap tests if no static key #247

Merged
merged 1 commit into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions salem/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ def requires_matplotlib(test):
return test if has_matplotlib else unittest.skip(msg)(test)


def requires_static_key(test):
msg = "requires google static map key"
do_test = (("STATIC_MAP_API_KEY" in os.environ) and
(os.environ.get("STATIC_MAP_API_KEY")))
return test if do_test else unittest.skip(msg)(test)


def requires_motionless(test):
msg = "requires motionless"
return test if has_motionless else unittest.skip(msg)(test)
Expand Down
5 changes: 4 additions & 1 deletion salem/tests/test_graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
GoogleVisibleMap, open_wrf_dataset, open_xr_dataset,
python_version, cache_dir, sample_data_dir)
from salem.utils import get_demo_file
from salem.tests import (requires_matplotlib, requires_cartopy)
from salem.tests import (requires_matplotlib, requires_cartopy, requires_static_key)

# Globals
current_dir = os.path.dirname(os.path.abspath(__file__))
Expand Down Expand Up @@ -810,6 +810,7 @@ def test_hef_topo_withnan():


@requires_matplotlib
@requires_static_key
@pytest.mark.mpl_image_compare(baseline_dir=baseline_dir, tolerance=25)
def test_gmap():
g = GoogleCenterMap(center_ll=(10.762660, 46.794221), zoom=13,
Expand All @@ -828,6 +829,7 @@ def test_gmap():


@requires_matplotlib
@requires_static_key
@pytest.mark.mpl_image_compare(baseline_dir=baseline_dir, tolerance=25)
def test_gmap_transformed():
dem = GeoTiff(get_demo_file('hef_srtm.tif'))
Expand Down Expand Up @@ -857,6 +859,7 @@ def test_gmap_transformed():


@requires_matplotlib
@requires_static_key
@pytest.mark.mpl_image_compare(baseline_dir=baseline_dir, tolerance=10)
def test_gmap_llconts():
# This was because some problems were left unnoticed by other tests
Expand Down
Loading