From 5c3201090b363753a05d54603906230f3e45083c Mon Sep 17 00:00:00 2001 From: Sujen Shah Date: Tue, 13 Oct 2026 11:52:45 -0700 Subject: [PATCH] test: fix stale stage_in tests, pin pystac, and run tests in CI before image build --- .github/workflows/docker-build.yml | 14 ++++++++++++++ docker/Dockerfile | 2 +- environment.yaml | 2 +- tests/test_stage_in.py | 13 +++++++------ 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 4b3b67b..cf9a171 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -14,7 +14,21 @@ on: type: boolean jobs: + test: + runs-on: ubuntu-24.04 + + steps: + - uses: actions/checkout@v7 + - uses: actions/setup-python@v7 + with: + python-version: '3.12' + - name: Install dependencies + run: pip install pytest cwltool==3.1.20250110105449 cwl_utils==0.35 PyYAML pystac==1.15.2 maap-py requests + - name: Run tests + run: pytest tests + build_and_push: + needs: test runs-on: ubuntu-latest diff --git a/docker/Dockerfile b/docker/Dockerfile index 3b41ce6..b106fb2 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -21,7 +21,7 @@ RUN pip install --no-cache-dir \ cwl_utils==0.35 \ PyYAML \ awscli \ - pystac \ + pystac==1.15.2 \ maap-py \ requests diff --git a/environment.yaml b/environment.yaml index 352cd0a..fd98240 100644 --- a/environment.yaml +++ b/environment.yaml @@ -3,5 +3,5 @@ dependencies: - cwltool==3.1.20250110105449 - cwl_utils==0.35 - nodejs - - pystac + - pystac==1.15.2 - maap-py \ No newline at end of file diff --git a/tests/test_stage_in.py b/tests/test_stage_in.py index 41cb2d1..2181c86 100644 --- a/tests/test_stage_in.py +++ b/tests/test_stage_in.py @@ -445,10 +445,11 @@ def test_stac_extensions_preserved(self, mock_download, tmp_path): parent_container = Mock() result = _download_single_item(item_json, str(tmp_path), parent_container) - assert result.stac_extensions == [ - "https://stac-extensions.github.io/eo/v1.0.0/schema.json", - "https://stac-extensions.github.io/sar/v0.9.0/schema.json" - ] + # pystac may migrate extension schemas to newer versions on read, + # so check that each extension is preserved without pinning its version. + assert len(result.stac_extensions) == 2 + assert any("/eo/" in ext for ext in result.stac_extensions) + assert any("/sar/" in ext for ext in result.stac_extensions) @patch('stage_in.maap.downloadGranule') def test_stac_extensions_empty_list_preserved(self, mock_download, tmp_path): @@ -530,7 +531,7 @@ def test_links_cleared_and_self_href_reset(self, mock_download, tmp_path): @patch('stage_in.maap.downloadGranule') def test_self_href_set_to_local_path(self, mock_download, tmp_path): - """Self href should be set to the resolved absolute path of /.""" + """Self href should be the resolved absolute path of //.json.""" mock_download.return_value = str(tmp_path / "test-item-meta" / "asset.tif") item_json = { @@ -549,7 +550,7 @@ def test_self_href_set_to_local_path(self, mock_download, tmp_path): parent_container = Mock() result = _download_single_item(item_json, str(tmp_path), parent_container) - expected_self_href = str((tmp_path / "test-item-meta").resolve()) + expected_self_href = str((tmp_path / "test-item-meta" / "test-item-meta.json").resolve()) actual_self_href = result.get_self_href() assert actual_self_href == expected_self_href