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 .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ jobs:
steps:
- uses: actions/checkout@v6
- uses: chartboost/ruff-action@v1
with:
version: "0.15.7"
src: "HydroEO"

unit-tests:
needs: lint
Expand Down
2 changes: 1 addition & 1 deletion HydroEO/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def fetch_swot_raster(
end: str = typer.Option(..., "--end", help="End date (YYYY-MM-DD)."),
aoi_name: str = typer.Option("aoi", "--aoi-name", help="Label for the AOI."),
product: str = typer.Option(
"SWOT_L2_HR_PIXC_2.0", "--product", help="SWOT raster product short name."
"SWOT_L2_HR_Raster_D", "--product", help="SWOT raster product short name."
),
output: str = typer.Option(
"hydroeo_output", "--output", "-o", help="Output directory (created if absent)."
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ exclude = ["notebooks", "tests", "images"]
[project]
# name on PyPI (e.g. pip install HydroEO)
name = "HydroEO"
version = "0.2.2"
version = "0.2.3"
dependencies = [
"earthaccess>=0.9.0,<2.0",
"h5netcdf>=1.3.0,<2.0",
Expand Down
20 changes: 15 additions & 5 deletions tests/unit/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from __future__ import annotations

import os
from pathlib import Path
from unittest.mock import MagicMock, patch

Expand Down Expand Up @@ -136,12 +137,15 @@ def test_fetch_swot_raster_calls_download_raster(tmp_path):
cfg = call_kwargs["config"]
assert cfg["aoi"]["type"] == "bbox"
assert cfg["aoi"]["bbox"] == [-10.0, 40.0, 10.0, 60.0]
assert cfg["product"] == "SWOT_L2_HR_Raster_D"


@pytest.mark.unit
def test_fetch_swot_raster_credentials_from_env(tmp_path, monkeypatch):
monkeypatch.setenv("EARTHACCESS_USERNAME", "envuser")
monkeypatch.setenv("EARTHACCESS_PASSWORD", "envpass")
monkeypatch.delenv("EARTHDATA_USERNAME", raising=False)
monkeypatch.delenv("EARTHDATA_PASSWORD", raising=False)
with patch("HydroEO.satellites.swot.raster.download_raster") as mock_dl:
result = runner.invoke(
app,
Expand All @@ -154,12 +158,16 @@ def test_fetch_swot_raster_credentials_from_env(tmp_path, monkeypatch):
],
)
assert result.exit_code == 0, result.output
creds = mock_dl.call_args.kwargs["credentials"]
assert creds == ("envuser", "envpass")
mock_dl.assert_called_once()
assert "credentials" not in mock_dl.call_args.kwargs
assert os.environ["EARTHDATA_USERNAME"] == "envuser"
assert os.environ["EARTHDATA_PASSWORD"] == "envpass"


@pytest.mark.unit
def test_fetch_swot_raster_credentials_from_args(tmp_path):
def test_fetch_swot_raster_credentials_from_args(tmp_path, monkeypatch):
monkeypatch.delenv("EARTHDATA_USERNAME", raising=False)
monkeypatch.delenv("EARTHDATA_PASSWORD", raising=False)
with patch("HydroEO.satellites.swot.raster.download_raster") as mock_dl:
result = runner.invoke(
app,
Expand All @@ -176,8 +184,10 @@ def test_fetch_swot_raster_credentials_from_args(tmp_path):
],
)
assert result.exit_code == 0, result.output
creds = mock_dl.call_args.kwargs["credentials"]
assert creds == ("arguser", "argpass")
mock_dl.assert_called_once()
assert "credentials" not in mock_dl.call_args.kwargs
assert os.environ["EARTHDATA_USERNAME"] == "arguser"
assert os.environ["EARTHDATA_PASSWORD"] == "argpass"


@pytest.mark.unit
Expand Down
Loading
Loading