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
15 changes: 15 additions & 0 deletions pixi.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -138,5 +138,6 @@ shapely = "*"

[tool.pixi.feature.dev.dependencies]
flake8 = "*"
fsspec = "*"
pytest = ">=4.6"
pytest-cov = "*"
14 changes: 12 additions & 2 deletions tests/test_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import os
import shutil
import numpy as np
import pytest
import pointCollection as pc
from pointCollection.scripts.query_ATL11_cloud import (
read_ATL11_granule_cloud, read_ATL11_granule_cloud_items)
Expand Down Expand Up @@ -106,9 +107,18 @@ def test_read_ATL11_granule_cloud_merges_items(tmp_path):
assert merged.size == sum(Di.size for Di in items)


def test_read_ATL11_granule_cloud_items_missing_index_raises(tmp_path):
"""by default, a missing index is a staging error"""
with pytest.raises(FileNotFoundError, match='missing geoIndex'):
read_ATL11_granule_cloud_items(
'not-a-real-granule.h5', str(tmp_path / 'no_such_index.h5'), [-1, 1], [-1, 1])


def test_read_ATL11_granule_cloud_items_missing_index_returns_none(tmp_path):
items = read_ATL11_granule_cloud_items(
'not-a-real-granule.h5', str(tmp_path / 'no_such_index.h5'), [-1, 1], [-1, 1])
with pytest.warns(UserWarning, match='missing geoIndex'):
items = read_ATL11_granule_cloud_items(
'not-a-real-granule.h5', str(tmp_path / 'no_such_index.h5'), [-1, 1], [-1, 1],
missing_index='skip')
assert items is None


Expand Down
13 changes: 11 additions & 2 deletions tests/test_cloud_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,23 @@ def test_remote_index_is_not_reported_missing(tmp_path):
assert items is not None and len(items) > 0


def test_missing_remote_index_raises(tmp_path):
"""by default, a remote index that really is absent is a staging error"""
index_fs = FakeS3FS({})
with pytest.raises(FileNotFoundError, match='missing geoIndex'):
read_ATL11_granule_cloud_items(
'ATL11_044110_0331_007_04.h5', 's3://bucket/no_such_index.h5',
[-1, 1], [-1, 1], index_fs=index_fs)


def test_missing_remote_index_still_skips(tmp_path):
"""a remote index that really is absent must still warn and skip"""
"""with missing_index='skip', an absent remote index must warn and skip"""
index_fs = FakeS3FS({})
import warnings
with warnings.catch_warnings(record=True) as caught:
warnings.simplefilter('always')
items = read_ATL11_granule_cloud_items(
'ATL11_044110_0331_007_04.h5', 's3://bucket/no_such_index.h5',
[-1, 1], [-1, 1], index_fs=index_fs)
[-1, 1], [-1, 1], index_fs=index_fs, missing_index='skip')
assert items is None
assert any('missing geoIndex' in str(w.message) for w in caught)
Loading