Skip to content

Commit

Permalink
add test of getting EarthdataClient from url factory
Browse files Browse the repository at this point in the history
  • Loading branch information
ircwaves committed Oct 29, 2024
1 parent f121c93 commit c728463
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tests/test_earthdata_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,26 @@
import pytest

from stac_asset import Config, EarthdataClient
from stac_asset.client import Clients

pytestmark = [
pytest.mark.skipif(
os.environ.get("EARTHDATA_PAT") is None,
reason="EARTHDATA_PAT is not set",
),
pytest.mark.asyncio,
pytest.mark.network_access,
]


@pytest.mark.network_access
async def test_download_href(tmp_path: Path) -> None:
href = "https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/MYD11A1.061/MYD11A1.A2023145.h14v17.061.2023146183035/MYD11A1.A2023145.h14v17.061.2023146183035.hdf"
async with await EarthdataClient.from_config(Config()) as client:
await client.download_href(href, tmp_path / "out.hdf")
assert os.path.getsize(tmp_path / "out.hdf") == 197419


async def test_get_earthdata_client() -> None:
href = "https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/MOD21A1D.061/MOD21A1D.A2020253.h08v05.061.2020346022258/MOD21A1D.A2020253.h08v05.061.2020346022258.hdf"
clients = Clients(Config())
assert isinstance(await clients.get_client(href=href), EarthdataClient)

0 comments on commit c728463

Please sign in to comment.