Skip to content
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
3 changes: 3 additions & 0 deletions src/earthkit/data/utils/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,16 @@ def modules_installed(*modules):
fdb_home = os.environ.get("FDB_HOME", None)
NO_PROD_FDB = fdb_home is None

NO_ODC = not modules_installed("pyodc") and not modules_installed("codc")
NO_GRIBJUMP = NO_FDB or not modules_installed("pygribjump")
NO_POLYTOPE = not os.path.exists(os.path.expanduser("~/.polytopeapirc"))
NO_COVJSONKIT = not modules_installed("covjsonkit")
NO_RIOXARRAY = not modules_installed("rioxarray")

NO_S3_AUTH = not modules_installed("aws_requests_auth")
NO_GEO = not modules_installed("earthkit-geo")
NO_GEOPANDAS = not modules_installed("geopandas")

try:
NO_ECFS = not os.path.exists(shutil.which("ecp"))
except Exception:
Expand Down
5 changes: 4 additions & 1 deletion tests/high_level_object/test_hl_geojson_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
# nor does it submit to any jurisdiction.
#

import pytest

from earthkit.data import from_source
from earthkit.data.utils.testing import earthkit_test_data_file
from earthkit.data.utils.testing import NO_GEOPANDAS, earthkit_test_data_file


@pytest.mark.skipif(NO_GEOPANDAS, reason="geopandas is not installed")
def test_hl_geojson_single_core():
ds = from_source("file", earthkit_test_data_file("NUTS_RG_20M_2021_3035.geojson"))

Expand Down
4 changes: 4 additions & 0 deletions tests/high_level_object/test_hl_geopandas_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
# nor does it submit to any jurisdiction.
#

import pytest

pytest.importorskip("geopandas")

from earthkit.data import from_object
from earthkit.data.utils.testing import earthkit_test_data_file

Expand Down
7 changes: 6 additions & 1 deletion tests/high_level_object/test_hl_odb_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@
# nor does it submit to any jurisdiction.
#

import pytest

from earthkit.data import from_source
from earthkit.data.utils.testing import earthkit_examples_file
from earthkit.data.utils.testing import NO_ODC, earthkit_examples_file

if NO_ODC:
pytest.skip("pyodc is not installed", allow_module_level=True)


def test_hl_odb_single_core():
Expand Down
5 changes: 4 additions & 1 deletion tests/high_level_object/test_hl_shapefile_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
# nor does it submit to any jurisdiction.
#

import pytest

from earthkit.data import from_source
from earthkit.data.utils.testing import earthkit_test_data_file
from earthkit.data.utils.testing import NO_GEOPANDAS, earthkit_test_data_file


@pytest.mark.skipif(NO_GEOPANDAS, reason="geopandas is not installed")
def test_hl_shapefile_single_core():
d = from_source("file", earthkit_test_data_file("NUTS_RG_20M_2021_3035.shp.zip"))

Expand Down
3 changes: 2 additions & 1 deletion tests/high_level_object/test_hl_target_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from earthkit.data.core.temporary import temp_file
from earthkit.data.encoders.grib import GribEncoder
from earthkit.data.targets import to_target
from earthkit.data.utils.testing import NO_RIOXARRAY, earthkit_examples_file, earthkit_test_data_file
from earthkit.data.utils.testing import NO_ODC, NO_RIOXARRAY, earthkit_examples_file, earthkit_test_data_file


@pytest.mark.parametrize(
Expand Down Expand Up @@ -133,6 +133,7 @@ def test_hl_target_file_csv():
assert list(df1.columns) == ["h1", "h2", "h3", "name"]


@pytest.mark.skipif(NO_ODC, reason="pyodc is not installed")
def test_hl_target_file_odb():
ds = from_source("file", earthkit_examples_file("test.odb"))
assert ds._TYPE_NAME == "ODB"
Expand Down
6 changes: 5 additions & 1 deletion tests/odb/test_odb_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@
#

import numpy as np
import pytest

from earthkit.data import from_source
from earthkit.data.utils.testing import earthkit_examples_file
from earthkit.data.utils.testing import NO_ODC, earthkit_examples_file

if NO_ODC:
pytest.skip("pyodc is not installed", allow_module_level=True)


def test_odb_to_pandas():
Expand Down
7 changes: 6 additions & 1 deletion tests/odb/test_odb_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@
# nor does it submit to any jurisdiction.
#

import pytest

from earthkit.data import from_source
from earthkit.data.utils.testing import earthkit_remote_examples_file
from earthkit.data.utils.testing import NO_ODC, earthkit_remote_examples_file

if NO_ODC:
pytest.skip("pyodc is not installed", allow_module_level=True)


def test_odb_url():
Expand Down
5 changes: 4 additions & 1 deletion tests/readers/test_geojson_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
import pytest

from earthkit.data import from_source
from earthkit.data.utils.testing import earthkit_test_data_file
from earthkit.data.utils.testing import NO_GEOPANDAS, earthkit_test_data_file

if NO_GEOPANDAS:
pytest.skip("geopandas is not installed", allow_module_level=True)


def test_geojson():
Expand Down
6 changes: 5 additions & 1 deletion tests/readers/test_shapefile_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@
# nor does it submit to any jurisdiction.
#
import numpy as np
import pytest

from earthkit.data import from_source
from earthkit.data.utils.bbox import BoundingBox
from earthkit.data.utils.testing import earthkit_test_data_file
from earthkit.data.utils.testing import NO_GEOPANDAS, earthkit_test_data_file

if NO_GEOPANDAS:
pytest.skip("geopandas is not installed", allow_module_level=True)


def test_shapefile():
Expand Down
6 changes: 5 additions & 1 deletion tests/translators/test_pandas_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@

import logging

import geopandas as gpd
import pandas as pd
import pytest

from earthkit.data import from_object, transform
from earthkit.data.utils.testing import NO_GEOPANDAS

LOG = logging.getLogger(__name__)

Expand All @@ -42,7 +43,10 @@ def test_pd_dataframe_translator():
assert isinstance(transform(ds, pd.DataFrame), pd.DataFrame)


@pytest.mark.skipif(NO_GEOPANDAS, reason="geopandas is not installed")
def test_gpd_dataframe_translator():
import geopandas as gpd

val = gpd.GeoDataFrame()
ds = from_object(val)

Expand Down
Loading